Reputation: 8903
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?
Upvotes: 1
Views: 3554
Reputation: 49195
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
Upvotes: 2