ScriptManager only allows jQuery CDN backup using Microsoft ASP.NET CDN

How can I use any CDN ScriptManager

backup CDN for my custom jQuery ScriptResourceDefinition

?

When I use ajax.aspnetcdn.com

, my browser renders the tag <script>

with the CDN url correctly and then writes fallback code to write the new tag <script>

with the local url.

ASPX

<asp:ScriptManager ID="scriptManager" runat="server" EnablePartialRendering="true" EnableCdn="true" EnableCdnFallback="true">
    <Scripts>
        <asp:ScriptReference Name="jquery" />
    </Scripts>
</asp:ScriptManager>

      

CS

string jQueryVersion = "1.11.2";
ScriptManager.ScriptResourceMapping.AddDefinition(
    "jquery",
    new ScriptResourceDefinition()
    {
        DebugPath = "~/Scripts/jquery-" + jQueryVersion + ".js",
        Path = "~/Scripts/jquery-" + jQueryVersion + ".min.js",
        CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-" + jQueryVersion + ".js",
        CdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-" + jQueryVersion + ".min.js",
        CdnSupportsSecureConnection = true,
        LoadSuccessExpression = "window.jQuery"
    });

      

Output

<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
(window.jQuery)||document.write('<script type="text/javascript" src="Scripts/jquery-1.11.2.min.js"><\/script>');//]]>
</script>

      


Problem

If I use code.jquery.com

or ajax.googleapis.com

as a CDN server, I just get a local copy no matter what:

CS

...<snip>...
CdnDebugPath = "http://code.jquery.com/jquery-" + jQueryVersion + ".js",
CdnPath = "http://code.jquery.com/jquery-" + jQueryVersion + ".min.js",
...<snip>...

      

Output

<script src="Scripts/jquery-1.11.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
(window.jQuery)||document.write('<script type="text/javascript" src="Scripts/jquery-1.11.2.min.js"><\/script>');//]]>
</script>

      

+3


source to share





All Articles