I have a ScriptManager configured to use the CDN. It works great for everything except AJAX remotely. If I load the site on my local machine via 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?
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..
According to your description, I made a related inquiry about this issue. I have found that
if an assembly does not define a CDN path in its WebResourceAttributes, EnableCDN won't know where to go.
I see that you have added the appropriate CDN path for the corresponding reference, so I think the problem may be related to what you described at the end.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
My next question would be if it would be possible for me to define a CDN for the AJAXControlToolkit myself. I don't know how I would do that since I don't know of a way for me to edit assemblies created by others.
Do you mean you need to use custom scripts or third-party controls?
If this is the case, when you embed a script within an assembly for use by a WebForm, you have to define a WebResourceAttribute for it, which allows it to be accessed via the WebResource.axd or ScriptResource.axd handlers.
ScriptManager looks for this property when the EnableCdn property is set to true, and simply uses that path instead of the ScriptResource.axd path to the assembly resource. And this means that you too can provide your own CDN paths for your own assembly
resource scripts. As for where to host your script, well, that’s up to you.
Best regards,
Xudong Peng
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Bahis arbitrajının temellerini öğrenmek yeterince korkutucu olabilir. Bahis arbitraj web sitelerini incelediğinizde, kaçınılmaz olarak birçok yeni terminoloji ile karşılaşacaksınız. İyi haber şu ki, bunların çoğu asla göremeyeceğiniz özel durumlara
atıfta bulunuyor. mobil ödeme bahis
Member
5 Points
207 Posts
Script Manager Not Using CDN on Remote Host for MS AJAX
Dec 29, 2020 09:28 AM|CopBlaster|LINK
I have a ScriptManager configured to use the CDN. It works great for everything except AJAX remotely. If I load the site on my local machine via 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
Here is the BundleConfig.cs file
Here is the source code from a page running on my local machine WITHOUT SSL
Here is the source code from the website running live on a remote IIS server:
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..
Contributor
2080 Points
663 Posts
Re: Script Manager Not Using CDN on Remote Host for MS AJAX
Dec 30, 2020 10:32 AM|XuDong Peng|LINK
Hi CopBlaster,
According to your description, I made a related inquiry about this issue. I have found that if an assembly does not define a CDN path in its WebResourceAttributes, EnableCDN won't know where to go.
I see that you have added the appropriate CDN path for the corresponding reference, so I think the problem may be related to what you described at the end.
I found a good article about this:
https://weblogs.asp.net/infinitiesloop/asp-net-4-0-scriptmanager-improvements
Best regards,
Xudong Peng
Member
5 Points
207 Posts
Re: Script Manager Not Using CDN on Remote Host for MS AJAX
Dec 31, 2020 10:17 AM|CopBlaster|LINK
Thanks XuDong,
My next question would be if it would be possible for me to define a CDN for the AJAXControlToolkit myself. I don't know how I would do that since I don't know of a way for me to edit assemblies created by others.
Contributor
2080 Points
663 Posts
Re: Script Manager Not Using CDN on Remote Host for MS AJAX
Jan 05, 2021 02:32 AM|XuDong Peng|LINK
Hi CopBlaster,
Do you mean you need to use custom scripts or third-party controls?
If this is the case, when you embed a script within an assembly for use by a WebForm, you have to define a WebResourceAttribute for it, which allows it to be accessed via the WebResource.axd or ScriptResource.axd handlers.
Something like :
ScriptManager looks for this property when the EnableCdn property is set to true, and simply uses that path instead of the ScriptResource.axd path to the assembly resource. And this means that you too can provide your own CDN paths for your own assembly resource scripts. As for where to host your script, well, that’s up to you.
Best regards,
Xudong Peng
None
0 Points
1 Post
Re: Script Manager Not Using CDN on Remote Host for MS AJAX
Feb 14, 2021 10:32 AM|williamc.balcom|LINK
Bahis arbitrajının temellerini öğrenmek yeterince korkutucu olabilir. Bahis arbitraj web sitelerini incelediğinizde, kaçınılmaz olarak birçok yeni terminoloji ile karşılaşacaksınız. İyi haber şu ki, bunların çoğu asla göremeyeceğiniz özel durumlara atıfta bulunuyor. mobil ödeme bahis