简体   繁体   English

运行ASP.NET应用程序时typeof(Sys)==='undefined'错误

[英]typeof(Sys) === 'undefined' error when running ASP.NET app

I am developing a Web Application using WebForms with ASP.NET. 我正在使用带有ASP.NET的WebForms开发Web应用程序。 Using a ScriptManager, I am loading a custom javascript script file. 使用ScriptManager,我正在加载自定义javascript脚本文件。

When I view the page in browser, I do not get the intended action (display a timer) and "view source" on the page gives me the following error message: 当我在浏览器中查看页面时,没有得到预期的操作(显示计时器),并且页面上的“查看源代码”显示以下错误消息:

//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>

In my attempts to troubleshoot, I have used the same javascript file in an ASP.NET Website and it works fine. 在尝试进行故障排除时,我在ASP.NET网站中使用了相同的javascript文件,并且工作正常。 It only seems to happen with a Web Application. 它似乎只在Web应用程序中发生。 I've also added an alert into my javascript file, which works fine on both Website and Web Application. 我还向我的javascript文件中添加了一个警报,该警报在“网站”和“ Web应用程序”上均可正常运行。

There are two possible reasons for this error. 此错误有两个可能的原因。

First is that you do not have include the ScriptManager, but because as you say you have included it, the second reason is that you need to move the ScriptManager before the call of the "sys" so can be found by the rest script that throw this error. 首先是您没有包括ScriptManager,但是因为正如您说的那样包含了它,第二个原因是您需要在调用“ sys”之前移动ScriptManager,以便可以通过抛出该脚本的其余脚本找到它。这个错误。

So move the ScriptManager upper, or move your script lower than ScriptManager. 因此,将ScriptManager移至上方,或将脚本移至ScriptManager下方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM