Skip to content

C# ASP.NET cdn reference appears without being written in the code

Recently I came across this issue with Visual Studio 2015, while developing a website. I used ScriptManager to load javaScript to my web application. When I inspected the code of the site I noticed a message saying the page was loaded over HTTPS, but the CDN reference used HTTP, so the browser blocked it as mixed content. A further investigation revealed that the culprit was the script at http://ajax.aspnetcdn.com/ajax/4.6/1/WebForms.js, which, of course, was not written or referenced anywhere in the code.

Alas, I discovered the issue: the property “EnableCdn” on the ScriptManager was set to “true”.  To fix the issue (remove the unnecessary reference) just change it to “false”. If this file is required by your project, I recommend adding it like a regular JS and not from this CDN. Firstly, it’s from an unsecured location, secondly, using a CDN is not for publishing, as it might not be available, or change without notice (yes, even if it’s from Microsoft!)

Change to:

<script src=”http://ajax.aspnetcdn.com/ajax/4.6/1/WebForms.js” type=”text/javascript”></script>

Leave a Reply