我试图在用户的ScriptManager财产EnableCdn。 基本上我有这段代码在我的母版页文件:
<asp:ScriptManager ID="MainScriptManager" runat="server" EnablePartialRendering="true"
EnableScriptGlobalization="true" EnableScriptLocalization="true" AsyncPostBackTimeout="3600" EnableCdn="True">
这适用于我们通过HTTP连接的开发环境 - 它引用到这样的脚本:
<script src="http://ajax.aspnetcdn.com/ajax/4.5/5/WebForms.js" type="text/javascript"></script>
但在生产服务器上,在这里我们使用SSL它试图包括这样的脚本:
<script src="https://ajax.microsoft.com/ajax/4.0/2/WebForms.js" type="text/javascript"></script>
有两个differencies(版本和域),但是从4.0版本的最重要的文件是不CDN服务器上(通过HTTPS!)。
任何人都可以提出某种对于这个问题的解决? 这是否意味着,4.0版不通过HTTPS支持,但它是通过HTTP(我可以通过两种方法从下载4.5版文件,而4.0是只能通过HTTP)。
编辑:
我发现信息“ajax.microsoft.com更名为ajax.aspnetcdn.com” - 这似乎是我的版本问题,但我无法找到的信息(还)如何更改域名为正确的一个。 我们应该重新安装在生产框架?
该文件是在服务器上,但它只是被形迹十分烦躁最近(甚至无法访问所有现在的任何文件),因此请务必使用一个本地故障切换。
对于.NET 4.0只是添加到您的Global.asax文件 - 它更新所有用新的CDN域(以前的版本只需要改变相应的链接):
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
}
);
}
结帐这个链接
我知道这这么想的解决问的问题。 但这种清除多一点,我们怎么可以用它作为这个链接解释得很好。 它具有类似的语法,“尼古拉·诺维奇”已经提到,但它也包括将在CDN的情况下可以使用不响应请求的本地路径。
对于如。 (示例代码):
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"
});