We have a site served on a web farm. The farm is behind an SSL Accellerator which handles the encryption. This means that our IIS servers see all incoming connections as http, even though users all connect to the site via https.
We are beginning to use the EnableCDN=true property of ScriptManager. While on our dev environments where there is no SSL Accellerator the references to the js files on the CDN are rendered with https, on the production environment they are rendered insecurely over http which is causing the js to be blocked with "Only secure content is displayed" errors.
Short of manually updating all the script references in scriptmanager or re-writing the HTML on the way out via a module, does anyone know of a way to force the scriptmanager to render its references via https?
EDIT:
After doing some reflector review, I don't believe this is possible. I've put the following hack into place, however this is obviously fragile as it involves accessing a private field. If anyone can see a better way I would love to hear it.
var secureConnectionField = ScriptManager.GetType().GetField("_isSecureConnection", BindingFlags.Instance | BindingFlags.NonPublic);
if (secureConnectionField != null)
secureConnectionField.SetValue(ScriptManager, true);
If you use ASP.NET 4.0 or higher then one of the solution is to use ScriptResourceMapping feature of the ScriptManager control.
For example in global asax you can add the following code:
void Application_Start(object sender, EventArgs e) {
// map a simple name to a path
ScriptManager.ScriptResourceMapping.AddDefinition("jQuery", new ScriptResourceDefinition {
Path = "~/scripts/jquery-1.3.2.min.js",
DebugPath = "~/scripts/jquery-1.3.2.js",
CdnPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.3.2.min.js",
CdnDebugPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.3.2.js"
});
}
So, as you can see you can set CDN paths explicitly. Also, you can override the script mapping for standard Ajax files.
More information can be found in this article: http://weblogs.asp.net/infinitiesloop/archive/2009/11/23/asp-net-4-0-scriptmanager-improvements.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With