ASP.NET Ajax客户端框架无法加载.将ScriptManager放在空白页面上时

Sar*_*nyu 20 asp.net

我有一个错误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>
Run Code Online (Sandbox Code Playgroud)

这就是结束它的原因

<!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>
Run Code Online (Sandbox Code Playgroud)

问题可能是我曾经在我的项目中使用AjaxControlToolkit但后来我使用jquery代替.所以项目中的某个地方可能会尝试添加我无法找到它的Ajaxcontroltoolkit.我不知道如何解决这个错误.我试图添加ajaxcontroltoolkit的bin文件,但它似乎无法正常工作.

小智 36

这个解决方案对我有用:

客户端的错误是:

SCRIPT5022:ASP.NET Ajax客户端框架无法加载.

SCRIPT5009:'系统'未定义

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

.NET 4.0的解决方案是:

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

<asp:ScriptManager ID="ScriptManager1" runat="server" EnableCdn="true">
Run Code Online (Sandbox Code Playgroud)

Next Solution和Better Solution是:

将此处理程序添加到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>
Run Code Online (Sandbox Code Playgroud)

  • 你先生,是个圣徒.我一直试图解决这个问题一段时间,你的解决方案有效.谢谢! (2认同)
  • 我正在运行.NET 4.5,这个(EnableCdn属性)是唯一有效的解决方案.我不知道为什么这没有标记为答案.我已经挖了好几天了,甚至在这个问题上尝试了明显的答案都无济于事.就我而言,错误只发生在本地运行时,而不是在部署时发生.问题:为什么你的第二个解决方案比EnableCdn更受欢迎? (2认同)

Ash*_*ngh 22

未定义的系统意味着您没有在浏览器上加载客户端文件.

解决方案1:

<add verb="GET"
  path="ScriptResource.axd"
  type="Microsoft.Web.Handlers.ScriptResourceHandler"
  validate="false"/>
Run Code Online (Sandbox Code Playgroud)

解决方案2:如果您没有此功能,请将此添加<assemblies>

<add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Run Code Online (Sandbox Code Playgroud)

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

解决方案4:将其添加到您的web.config中

<location path="ScriptResource.axd">
   <system.web>
      <authorization>
         <allow users="*"/>
      </authorization>
   </system.web>
</location>
Run Code Online (Sandbox Code Playgroud)

  • 在<configuration> <system.web> <httpHandlers>下的web.config中 (3认同)
  • 放在哪里<add verb ="GET"path ="ScriptResource.axd"type ="Microsoft.Web.Handlers.ScriptResourceHandler"validate ="false"/> (2认同)

小智 5

对于Telerik Web资源,请使用以下代码:

<location path="Telerik.Web.UI.WebResource.axd">
<system.web>
  <authorization>
    <allow users="*"/>
  </authorization>
</system.web>
Run Code Online (Sandbox Code Playgroud)