SyntaxHighlighter Build Test Page
Thoughts from a C# Developer
kennydust (gravatar)

Microsoft AJAX CDN for ASP.NET 3.5

Late last year, Microsoft announced the launch of their caching support service aka their CDN service, for their ASP.NET AJAX libraries (and the third party jquery libraries) at no cost. Sweet!

The problem was, you needed to be up-to-date on ASP.NET 4.0 framework stack in order to take advantage of it. Luckily, the community banned together in an uproar, and shortly thereafter a fix was released. While it’s practically plug-and-play if you’ve running ASP.NET 4.0, some custom code is required to get it to work correctly in the 3.5 framework. I ran across an excellent blog about this, and it details much more than I was looking for.

To paraphrase, you need to define a <script> region in your scriptmanager instance and hardcode the CDN path, this will override the default local script reference location:


I wanted to encapulate the logic a little better, so I wrote a small control that inherits the scriptmanager, and conditionally loads from the CDN, because I work without an internet connection at times:

    public class CustomScriptManagerControl : ScriptManager
        /// Microsoft Ajax 3.5 reference.
        private const string CDN_PATH = "";

        protected override void OnInit(EventArgs e)

#if !DEBUG
            Scripts.Add(new ScriptReference { Name = "MicrosoftAjax.js", Path = CDN_PATH });


this is called in my consuming page:


Your Information
Mrs. Gravatar (gravatar)

<-- It's a gravatar

your comment