ScriptManager EnableCdn - does not work on SSL
Asked Answered
Q

3

5

I am trying to user EnableCdn property in ScriptManager. Basically I have this piece of code in my master page file:

<asp:ScriptManager ID="MainScriptManager" runat="server" EnablePartialRendering="true"
    EnableScriptGlobalization="true" EnableScriptLocalization="true" AsyncPostBackTimeout="3600" EnableCdn="True">

This works on the dev environment where we connect via HTTP - it references to such script:

<script src="http://ajax.aspnetcdn.com/ajax/4.5/5/WebForms.js" type="text/javascript"></script>

But on the production server, where we use SSL it tries to include such script:

<script src="https://ajax.microsoft.com/ajax/4.0/2/WebForms.js" type="text/javascript"></script>

There are two differencies (version and the domain), but most of all this file from version 4.0 is not on the CDN server (via https!).

Could anyone suggest some sort of resolution for this problem? Does that mean that version 4.0 is not supported via https, but it is via http (I can download file from version 4.5 by both methods, but 4.0 is only available via HTTP).

EDIT:

I have found information that "ajax.microsoft.com renamed to ajax.aspnetcdn.com" - this seems to be a problem with my version but I cannot find information (yet) how to change the domain into correct one. Should we reinstall framework on the production?

Quitrent answered 14/8, 2012 at 9:33 Comment(2)
Can you confirm that your production environment is running the same version of .NET that your dev environment is? It appears that you're running .NET 4.5 RC in your dev environment, and .NET 4.0 in your production environment.Wychelm
That seems to be problem - I have asked the release team to install .NET 4.5 RTM on our production environment.Quitrent
I
7

The files are on the server, but it's just been acting very fidgety lately (can't even access any file at all right now), so always use a local failover.

For .Net 4.0 just add this to your Global.asax file - it updates all the CDN domains with the new one (for previous versions just change the links appropriately):

protected void Application_Start(object sender, EventArgs e)
{
    System.Reflection.Assembly web = typeof(HttpApplication).Assembly;
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "WebForms.js",
        web,
        new ScriptResourceDefinition
        {
            ResourceName = "WebForms.js",
            ResourceAssembly = web,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/WebForms.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/WebForms.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "Focus.js",
        web,
        new ScriptResourceDefinition
        {
            ResourceName = "Focus.js",
            ResourceAssembly = web,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/Focus.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/Focus.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "SmartNav.js",
        web,
        new ScriptResourceDefinition
        {
            ResourceName = "SmartNav.js",
            ResourceAssembly = web,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/SmartNav.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/SmartNav.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "WebUIValidation.js",
        web,
        new ScriptResourceDefinition
        {
            ResourceName = "WebUIValidation.js",
            ResourceAssembly = web,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/WebUIValidation.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/WebUIValidation.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "TreeView.js",
        web,
        new ScriptResourceDefinition
        {
            ResourceName = "TreeView.js",
            ResourceAssembly = web,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/TreeView.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/TreeView.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "Menu.js",
        web,
        new ScriptResourceDefinition
        {
            ResourceName = "Menu.js",
            ResourceAssembly = web,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/Menu.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/Menu.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "MenuStandards.js",
        web,
        new ScriptResourceDefinition
        {
            ResourceName = "MenuStandards.js",
            ResourceAssembly = web,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MenuStandards.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MenuStandards.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "WebParts.js",
        web,
        new ScriptResourceDefinition
        {
            ResourceName = "WebParts.js",
            ResourceAssembly = web,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/WebParts.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/WebParts.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "GridView.js",
        web,
        new ScriptResourceDefinition
        {
            ResourceName = "GridView.js",
            ResourceAssembly = web,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/GridView.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/GridView.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "DetailsView.js",
        web,
        new ScriptResourceDefinition
        {
            ResourceName = "DetailsView.js",
            ResourceAssembly = web,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/DetailsView.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/DetailsView.js",
            CdnSupportsSecureConnection = true
        }
    );
    System.Reflection.Assembly ext = typeof(ScriptManager).Assembly;
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "MicrosoftAjax.js",
        ext,
        new ScriptResourceDefinition
        {
            ResourceName = "MicrosoftAjax.js",
            ResourceAssembly = ext,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjax.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjax.debug.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "MicrosoftAjaxApplicationServices.js",
        ext,
        new ScriptResourceDefinition
        {
            ResourceName = "MicrosoftAjaxApplicationServices.js",
            ResourceAssembly = ext,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxApplicationServices.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxApplicationServices.debug.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "MicrosoftAjaxComponentModel.js",
        ext,
        new ScriptResourceDefinition
        {
            ResourceName = "MicrosoftAjaxComponentModel.js",
            ResourceAssembly = ext,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxComponentModel.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxComponentModel.debug.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "MicrosoftAjaxCore.js",
        ext,
        new ScriptResourceDefinition
        {
            ResourceName = "MicrosoftAjaxCore.js",
            ResourceAssembly = ext,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxCore.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxCore.debug.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "MicrosoftAjaxGlobalization.js",
        ext,
        new ScriptResourceDefinition
        {
            ResourceName = "MicrosoftAjaxGlobalization.js",
            ResourceAssembly = ext,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxGlobalization.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxGlobalization.debug.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "MicrosoftAjaxHistory.js",
        ext,
        new ScriptResourceDefinition
        {
            ResourceName = "MicrosoftAjaxHistory.js",
            ResourceAssembly = ext,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxHistory.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxHistory.debug.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "MicrosoftAjaxNetwork.js",
        ext,
        new ScriptResourceDefinition
        {
            ResourceName = "MicrosoftAjaxNetwork.js",
            ResourceAssembly = ext,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxNetwork.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxNetwork.debug.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "MicrosoftAjaxSerialization.js",
        ext,
        new ScriptResourceDefinition
        {
            ResourceName = "MicrosoftAjaxSerialization.js",
            ResourceAssembly = ext,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxSerialization.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxSerialization.debug.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "MicrosoftAjaxTimer.js",
        ext,
        new ScriptResourceDefinition
        {
            ResourceName = "MicrosoftAjaxTimer.js",
            ResourceAssembly = ext,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxTimer.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxTimer.debug.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "MicrosoftAjaxWebForms.js",
        ext,
        new ScriptResourceDefinition
        {
            ResourceName = "MicrosoftAjaxWebForms.js",
            ResourceAssembly = ext,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxWebForms.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxWebForms.debug.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "MicrosoftAjaxWebServices.js",
        ext,
        new ScriptResourceDefinition
        {
            ResourceName = "MicrosoftAjaxWebServices.js",
            ResourceAssembly = ext,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxWebServices.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/MicrosoftAjaxWebServices.debug.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "Date.HijriCalendar.js",
        ext,
        new ScriptResourceDefinition
        {
            ResourceName = "Date.HijriCalendar.js",
            ResourceAssembly = ext,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/Date.HijriCalendar.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/Date.HijriCalendar.debug.js",
            CdnSupportsSecureConnection = true
        }
    );
    ScriptManager.ScriptResourceMapping.AddDefinition(
        "Date.UmAlQuraCalendar.js",
        ext,
        new ScriptResourceDefinition
        {
            ResourceName = "Date.UmAlQuraCalendar.js",
            ResourceAssembly = ext,
            CdnPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/Date.UmAlQuraCalendar.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/4.0/2/Date.UmAlQuraCalendar.debug.js",
            CdnSupportsSecureConnection = true
        }
    );
}
Intercourse answered 24/8, 2012 at 8:31 Comment(0)
P
0

I too have the same problem running 4.0 and i can't find anything which indicates how one should go about fixing this given the references to ajax.microsoft.com are placed by the framework itself.

Ptosis answered 23/8, 2012 at 11:15 Comment(1)
I will try to install .NET 4.5 RTM and verify whether the problem is still there.Quitrent
T
0

checkout this link

I know this dosen't solve the asked question. but this clears bit more how can we use it as this link explains it very well. It has similar syntax that "Nikola Bogdanovic" has mentioned, but it also includes the local path that will be used in case CDN doesn't respond to request.

For eg. (sample code):

string str = "1.7.1";

ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition

{

    Path = "~/Scripts/jquery-" + str + ".min.js", 

    DebugPath = "~/Scripts/jquery-" + str + ".js", 

    CdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-" + str + ".min.js", 

    CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-" + str + ".js", 

    CdnSupportsSecureConnection = true, 

    LoadSuccessExpression = "window.jQuery"

});
Tita answered 4/8, 2014 at 5:44 Comment(1)
LoadSuccessExpression property was added in .Net 4.5 - it did not yet exist at the time of my answer... you had to do local failover manually back thenIconoscope

© 2022 - 2024 — McMap. All rights reserved.