AjaxControlToolkit icon indicating copy to clipboard operation
AjaxControlToolkit copied to clipboard

CDN Does Not Work When Deployed to IIS

Open PostAlmostAnything opened this issue 4 years ago • 0 comments

I have a ScriptManager configured to use the CDN. It works great for everything except the AJAX toolkit remotely. If I load the site on my local machine all the AJAX scripts run off the CDN like they should, but when I upload it to my remote server I see no references to the CDN for AJAX and a bunch of references to ScriptResource.axd. What could cause the site not to use the CDN only on the remote host?

Here is the Script Manager

<asp:ScriptManager runat="server" EnableHistory="true" EnableSecureHistoryState="false" EnableCdn="True" EnableCdnFallback="True"> <Scripts> <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%> <%--Framework Scripts--%> <asp:ScriptReference Name="MsAjaxBundle" /> <asp:ScriptReference Name="jquery" /> <asp:ScriptReference Name="popper" /> <asp:ScriptReference Name="bootstrap" /> <asp:ScriptReference Name="respond" /> <asp:ScriptReference Name="lazysizes" /> <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" /> <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" /> <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" /> <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" /> <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" /> <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" /> <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" /> <asp:ScriptReference Name="WebFormsBundle" /> <%--Site Scripts--%> </Scripts> <Services> <asp:ServiceReference Path="/webservices/TagSearch.asmx" /> <asp:ServiceReference Path="/webservices/CitySearch.asmx" /> <asp:ServiceReference Path="/webservices/DCNames.asmx" /> <asp:ServiceReference Path="/webservices/DCAgencies.asmx" /> <asp:ServiceReference Path="/webservices/ExternalLink.asmx" /> <asp:ServiceReference Path="/webservices/insertdsc.asmx" /> </Services> </asp:ScriptManager>

Here is the BundleConfig.cs file

public class BundleConfig { // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkID=303951 public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/WebFormsJs").Include( "~/Scripts/WebForms/WebForms.js", "~/Scripts/WebForms/WebUIValidation.js", "~/Scripts/WebForms/MenuStandards.js", "~/Scripts/WebForms/Focus.js", "~/Scripts/WebForms/GridView.js", "~/Scripts/WebForms/DetailsView.js", "~/Scripts/WebForms/TreeView.js", "~/Scripts/WebForms/WebParts.js"));

        // Order is very important for these files to work, they have explicit dependencies
        bundles.Add(new ScriptBundle("~/bundles/MsAjaxJs").Include(
                "~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
                "~/Scripts/WebForms/MsAjax/MicrosoftAjaxApplicationServices.js",
                "~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js",
                "~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"));


        // Use the Development version of Modernizr to develop with and learn from. Then, when you’re
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));
        
        ScriptManager.ScriptResourceMapping.AddDefinition(
            "respond",
            new ScriptResourceDefinition
            {
                Path = "~/Scripts/respond.min.js",
                DebugPath = "~/Scripts/respond.js",
                CdnPath = "https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.0/respond.min.js",
                CdnDebugPath = "https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.0/respond.js",
                CdnSupportsSecureConnection = true

            });
        ScriptManager.ScriptResourceMapping.AddDefinition(
            "popper",
            new ScriptResourceDefinition
            {
                Path = "~/Scripts/umd/popper.min.js",
                DebugPath = "~/Scripts/umd.popper.js",
                CdnPath = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js",
                CdnDebugPath = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.js",
                CdnSupportsSecureConnection = true,
            });
        ScriptManager.ScriptResourceMapping.AddDefinition(
            "lazysizes",
            new ScriptResourceDefinition
            {
                Path = "~/lib/lazysizes/lazysizes.min.js",
                DebugPath = "~/lib/lazysizes/lazysizes.js",
                CdnPath = "https://cdnjs.cloudflare.com/ajax/libs/lazysizes/5.2.2/lazysizes.min.js",
                CdnDebugPath = "https://cdnjs.cloudflare.com/ajax/libs/lazysizes/5.2.2/lazysizes.js",
                CdnSupportsSecureConnection = true,
            });
    }
}

Here is the source code from a page running on my local machine WITHOUT SSL

UPDATE: Seems the problem is solely with the AJAX Control Toolkit and Nothing else. I am guessing since my remote server supports SSL only and upgrades insecure request that has something to do with it..

PostAlmostAnything avatar Dec 29 '20 10:12 PostAlmostAnything