You can see in the source of this site that some asp.net script files are being served from the microsoft cdn, while a couple others are not: http://www.deadlywind.com .
I'm currently using this in the root master file:
<ajaxToolkit:ToolkitScriptManager runat="Server" EnableScriptGlobalization="true"
EnableScriptLocalization="true"
EnableCdn="true"
LoadScriptsBeforeUI="false"
ID="ScriptManager1"
CompositeScript-ScriptMode="Release" />
On the site I have debug mode turned off in the web.config.
(adding clarification)
It appears that the Microsoft Ajax javascript files are still being served up by my server and not the CDN, via the scriptresource.axd references found in the source of the above mentioned website. My question is, why are these not using the CDN and how should I force them to?
You need to configure CDN URLs using WebResource attribute. For example:
<Assembly: System.Web.UI.WebResource("MyScript.js",
"application/x-javascript",
CdnPath := "http://myCdnServer/js/MyScript.js")>
There can be multiple entries and can be put in any code file (as this being an assembly level attribute) but recommended place for keeping these entries would be global.asax.
EDIT: additional info requested by OP
In .NET 4.0, if you want to use Microsoft provided scripts from CDN then you don't need to make WebResource entries. EnableCdn=True should do the trick but make sure that you are using AJAX Toolkit that supports .NET 4.0 (i.e. Toolkit version 40412). Visit http://www.asp.net/ajaxlibrary/cdn.ashx to get more information and list of files on Microsoft CDN.
For .NET 3.5, you have make CDN entries - you can get the script file list from above link and/or actual page source. Folks also uses script combining and then host the combined script on their own CDN for better performance. Check this link: http://www.hanselman.com/blog/ASPNETAjaxScriptCombiningAndMovingScriptResourceaxdsToStaticScripts.aspx
Related
I'm new with this code (Telerik ASP AJAX) there was another guy who is not here anymore, so we can't ask him to help..
There is a page with simple questionary.. it has been working on previous WEB server (based on IIS Windows 7).
After we built the new PC we also installed Win_7 and the same IIS, but the Telerik Version might be freshier.
..
There is a main page with PlaceHolder (PH) with RadScriptManager.
Then, from another code, RadRotator is created and added as a Control to the PH.
..
During debugging everithing is Ok, I can see how the code creates all the elements, creates RadRotator with success, and then the created Rotator is successfully passed to PH container.
''
But at the end of the way there is no Rotator visible at the page.
..
And I can't see it's references to it's script on the page as well.
It should be like that:
<script src="http://some path/2016.3.914/Rotator/RadRotator.js" type="text/javascript"></script>
But there is no such state on the final page.
The IIS is set to Integrated Mode, not Classic. Also the App is under NET4.
Why generally that would be?
If the question is not clear, please, ask me for clarification.
Well, sorry, I forgot to report the answer..
The problem was that in new version
RadScriptManager
should be replaced with
ScriptManager
.
This may be caused by many things and this fix is strange.
Ensure the Telerik CDN is enabled so you get the URLs as you said you expect. You need the RadScriptManager for this
Ensure access to those scripts is provided in your network (monitor the network requests, ensure they return 200 or 304, speakwith your network admins otherwise)
Ensure you are using an official version and not an internal build, only official releases have CDN
if you are using webresource requests, add <location> elements to the web.config to allow anonymous access to the Telerik handlers that fetch the resources
i have to add one page to an existing asp.net webforms website.
this will be added at runtime and i'm not allowed to redeploy the entire webapplication / website.
is the (recommended or only) solution to move the code behind code to the aspx file, or do i have other options?
i can't put code in the dll's, and dynamicly runned .cs files are only in the case of a website and not in the case of a webapplication, am i right?
and putting the code from my code behind in de aspx file will always work?
actually as long as their page link to yours via URL you web page doesn't necessary have to be in the same project, unless you're trying to reuse something.
Else technically your project is fine as a standalone and they can just link to yours.
Unless you're worried about the URL then you would have to either use an iframe or some other URL rewrite.
Just for reference: One solution would be to use a dynamic proxy and intercept and extend the existing webapp. Though this approach might be a little too involved for what you're trying to achieve.
LinFu
Castle
I am trying to ensure that stale images/js/css files in a cache will not be used after deploying a new version of an asp.net web application.
I'm currently looking in to the js aspect of this. First, ALL of my own scripts are registered through the System.Web.UI.ScriptManager with normal urls to js files. So, I've subclassed the ScriptManager and I tack a ?ver='x.x.x.x' on the end of the script url. I don't see any problem with that for my scripts with normal urls, however there are always a lot of ScriptResource.axd references and I am concerned about these scripts.
So, for example, lets say in my next version I update the AjaxControlToolkit dll. Will the scriptResource.axd urls be different from the urls used by the previous AjaxControlToolkit? The scriptResources.axd look pretty funky to me, so I am hoping they are generated with a hash of the assembly or something? I've been through a ton of literature on scriptResource.axd, but I haven't found anything on this topic. Anyone have any ideas?
Thanks for reading.
You're partially right. The format of resource URL is WebResource.axd?d=encrypted identifier&t=time stamp value. The "d" stands for the requested Web Resource. The "t" is the timestamp for the requested assembly, which can help in determining if there have been any changes to the resource.
In brief, the first parameter is encrypted assemblyName + "|" + resourceName value (by using internal Page.EncryptString method); the secondparameter is number of ticks of assembly was last written to date (by using File.GetLastWriteTime method).
So, using the next version or your assembly will change the resource URL (rebuild the assembly and/or change its version).
More information could be found here:
Working with Web Resources in
ASP.NET 2.0
WebResource.axd or how I learned to
love the embedded resource
I have a .Net 1.1 webapp.
I have a usercontrol (.ascx) that has links to 3 JS files in
script tags.
When I run the app and load a page with the usercontrol
all is fine and Firebug shows the js files listed.
But when I load another page that loads the usercontrol in a .aspx
in a new browser window Firebug reports 404 object not found
for the 3 JS files.
What could cause this??
Malcolm
You other .aspx page is in a different folder? Possible at a different level in the folder hierarchy? You need to adjust you JS file paths so that they are absolute paths.
You probably have the other page in a different location in the folder hierarchy. Perhaps reference you JS with a server side tag with a ~ in it.
So try changing your JS path to something like this:
<script type="text/javascript" src='<%=ResolveUrl("~/someFolder/functions.js")%>'></script>
Use a tool like Microsoft Fiddler to help you understand the issue.
You could try using a basepath in you pages. In that case each url/image/css/js reference in your website will be relative to the basepath. Using a basepath in your site will prevent big issues when moving files into/from folders.
I usually place the base tag into the master page.
<base href="<%=MyWebsite.Library.Configuration.BasePath%>" />
As you can see the basepath is requested from my configuration, but you can also use .NET code to dertermine the basepath.
Using this constructions saves me a lot of issues when developing my pages. Only problem is that Visual Studio does not completely known how to handle this which causes some warnings about incorrect CssClasses or links.
I using urlrewriter.net to implement friendly urls.
When I did the rewriting I used subfolders on occasions.
I found myself having problems with images and links and the ~ sign wasn't working for me. After reading a bit I found out that I'm not the only one with that problem and they recommended using full path "www.website.com/images/x.jpg" etc.
Now, I can't develop and QA because all of the links go to my real online website.
What can I do?
If the URL prefix is your only concern, have you thought about adding a key to your web.config for the URL prefix and then dynamically generate the path to your images that way?
By doing this you can easily migrate all the code up to production when finished, and then simply update the web.config to point everything to the proper server.
~ only works with ASP.NET Web Controls, not standard HTML controls.
A similar problem is when you have content pages (located in subfolders) referencing a masterpage in the application root. You need to use Image and Hyperlink controls in the MasterPage since the files are referenced from the location of the content page.
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/Test.png" AlternateText="" />
<asp:HyperLink ID="HyperLink1" runat="server"NavigateUrl="~/Test.aspx">HyperLink</asp:HyperLink>