如何在ScriptManager中添加Jquery cdn,如果加载失败,则从本地文件加载

如何在ScriptManager中添加Jquery cdn,如果加载失败,则从本地文件加载,jquery,asp.net,cdn,scriptmanager,Jquery,Asp.net,Cdn,Scriptmanager,在asp:ScriptManager中,我像这样加载jquery <asp:ScriptManager ID="ScriptManagerMasterPage" runat="server"> <Scripts> <asp:ScriptReference Path="~/Scripts/jquery-1.6.4.min.js" /> <asp:ScriptReference Path="~/Scripts/jque

在asp:ScriptManager中,我像这样加载jquery

<asp:ScriptManager ID="ScriptManagerMasterPage" runat="server">
    <Scripts>
        <asp:ScriptReference Path="~/Scripts/jquery-1.6.4.min.js" />
        <asp:ScriptReference Path="~/Scripts/jquery-ui-1.8.16.min.js" />
        <asp:ScriptReference Path="~/Scripts/tag-it.js" />
        <asp:ScriptReference Path="~/Scripts/MosJScript.js" />
        <asp:ScriptReference Path="~/Scripts/jquery.tools.min.js" />
        <asp:ScriptReference Path="~/Scripts/jquery.dragsort.js" />
        <asp:ScriptReference Path="~/Scripts/jquery.ad-gallery.pack.js" />
    </Scripts>
</asp:ScriptManager>


假设我想使用来自google的jQueryCDN,但是如果cdn文件无法加载,那么我将从本地机器加载。如何做到这一点。

我想您正在寻找类似的产品。搜索词为“回退”文件

<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined')
{
    document.write(unescape("%3Cscript src='/Scripts/jquery-1.3.2.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>

if(typeof jQuery==“未定义”)
{
write(unescape(“%3Cscript src=”/Scripts/jquery-1.3.2.min.js'type='text/javascript'%3E%3C/script%3E”);
}

您必须添加脚本资源映射定义。例如,请参见下面的文档:


然后,您必须将ScriptManager的EnableCdn属性设置为true,以启用CDN的使用。

谢谢,我们似乎无法在ScriptManager中使用此属性,对吗?您可以始终将该脚本块放在脚本文件中,并将其包含在ScriptManager中。注意:我对ScriptManager的执行顺序了解得不够,不知道它是否遵守顺序。我真的很怀疑您是否希望通过HTML中的代码来执行此操作。。。当CDN出现故障时,页面的加载时间可能非常糟糕-想象一下,如果CDN速度慢并且超时需要很长时间,那么它将阻塞页面,直到每个元素都超时为止。。。如果您不能信任CDN,请使用不同的CDN,即您可以信任的CDN。