首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >ASP.NET Ajax客户端框架加载失败。当将ScriptManager放在空白页上时

ASP.NET Ajax客户端框架加载失败。当将ScriptManager放在空白页上时
EN

Stack Overflow用户
提问于 2012-07-02 14:38:18
回答 21查看 85.4K关注 0票数 22

我有一个错误Microsoft JScript运行时错误: ASP.NET Ajax客户端框架无法加载。使用母版页在空白页上执行

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">

    <div>

    </div>
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnableCdn="True">
    </asp:ScriptManager>
    </form>
</body>
</html>

这就是它最终呈现的结果

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title></head>
<body>
    <form method="post" action="WebForm2.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNjE2OTgwNTY5ZGTfWA/dEX85PXBlbkKsVxeLKyIn+mJQ9piW5cbeNE+qww==" />
</div>

<script type="text/javascript"> 
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>


<script src="http://ajax.microsoft.com/ajax/4.0/2/WebForms.js" type="text/javascript"></script>


<script src="/ScriptResource.axd?d=6x_aX-LOcgUU-O_K6nM7ST5ViC_naT1e4_j-CY35ASRLpcKYpiapwTARuePHvx3llP-Xhl_AG_ubpM1BzkM5iyn9ThB3m7lmXKvkck0cxTcYiT-VbeKgamKxp9EwxBUyIQN6sSCU9SQm3tMtmzQWRg2&amp;t=ffffffffbad362a4" type="text/javascript"></script>
<script type="text/javascript"> 
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>

<script src="/ScriptResource.axd?d=khKEuZ4oUqBYvQxJ1ISpPVIW8_AWWc907q5_v74DI2ruWKTJpldq2osxPkAZ__hffe1Q6HTQUyTbL3Q1mD6MX7V65O5ibxKwb4NvN6ycdZ8vEJ-bz51MO-8uoaP2xioK6npm5n8vldI1d0sOCnH6yw2&amp;t=ffffffffbad362a4" type="text/javascript"></script>

    <div>

    </div>
    <script type="text/javascript"> 
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ScriptManager1', 'form1', [], [], [], 90, '');
//]]>
</script>

    </form>
</body>
</html>

问题可能是我过去在我的项目中使用了AjaxControlToolkit,但后来我使用了jquery。因此,项目中的某个地方可能会尝试添加Ajaxcontroltoolkit工具包,但我找不到它。我不知道如何修复这个错误。我试着将ajaxcontroltoolkit的bin文件添加回来,但似乎不起作用。

EN

回答 21

Stack Overflow用户

回答已采纳

发布于 2012-07-02 14:59:02

Sys未定义意味着您没有将客户端文件加载到您的浏览器上。

解决方案1:

<add verb="GET"
  path="ScriptResource.axd"
  type="Microsoft.Web.Handlers.ScriptResourceHandler"
  validate="false"/>

解决方案2:如果没有这个,也可以在<assemblies>下面添加这个

<add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

Solution3:如果这也不起作用,尝试删除"bin“文件夹中的文件,重新构建解决方案,并清除浏览器的缓存。

解决方案4:将此代码添加到您的web.config

<location path="ScriptResource.axd">
   <system.web>
      <authorization>
         <allow users="*"/>
      </authorization>
   </system.web>
</location>
票数 21
EN

Stack Overflow用户

发布于 2013-12-02 03:29:42

这个解决方案对我很有效:

客户端上的错误是:

SCRIPT5022:未能加载ASP.NET Ajax客户端框架。

SCRIPT5009:'Sys‘未定义

经过多次挖掘网站,以及更多的解决方案,我解决了这个问题:

.NET 4.0的解决方案是:

将脚本管理器的EnableCdn属性设置为true,如下所示:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnableCdn="true">

下一个更好的解决方案是:

将此处理程序添加到您的web.config

  <system.webServer>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated"/>
      <remove name="ScriptHandlerFactory"/>
      <remove name="ScriptHandlerFactoryAppServices"/>
      <remove name="ScriptResource"/>
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </handlers>
  </system.webServer>
票数 43
EN

Stack Overflow用户

发布于 2013-04-25 18:18:41

对于telerik web资源,请使用以下代码:

<location path="Telerik.Web.UI.WebResource.axd">
<system.web>
  <authorization>
    <allow users="*"/>
  </authorization>
</system.web>

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11288796

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档