javascript Sys.WebForms.PageRequestManager 在 IE11 中是未定义错误,在 IE10 及更低版本中工作正常

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20164753/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 17:54:26  来源:igfitidea点击:

Sys.WebForms.PageRequestManager is undefined error in IE11, working fine in IE10 and below

javascriptasp.net.netinternet-explorer

提问by Fahad Mullaji

My clients have updated their browser to IE11 from IE10. I am getting below error on page refresh Sys.WebForms.PageRequestManager is undefined.

我的客户已将他们的浏览器从 IE10 更新到 IE11。我在页面刷新时遇到以下错误 Sys.WebForms.PageRequestManager 未定义。

Please check my code

请检查我的代码

<asp:ScriptManager ID="scmMain" EnableCdn="false" runat="server" AsyncPostBackTimeout="0"
    ScriptMode="Release">
   </asp:ScriptManager>

<script type="text/javascript">
    Sys.Application.add_init(function () {
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(ieAjaxPageLoaded);
        Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(ieAjaxPageLoaded);
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(ieAjaxEndRequest);
        Sys.Application.add_load(NeoSpin_PageLoad);
    });

    function header_onclick() {
    }
    function End(sender, args) { }
</script>

This works fine on IE10 and below

这适用于 IE10 及以下

I have already tried below links - but no help -

我已经尝试过以下链接 - 但没有帮助 -

'Sys.WebForms.PageRequestManager' is null or not an object

'Sys.WebForms.PageRequestManager' 为空或不是对象

Microsoft JScript runtime error: 'Sys' is undefined

Microsoft JScript 运行时错误:“Sys”未定义

http://encosia.com/updated-your-webconfig-but-sys-is-still-undefined/

http://encosia.com/updated-your-webconfig-but-sys-is-still-undefined/

http://www.codeproject.com/Questions/543002/Unableplustoplusgetpluspropertyplus-27PageRequestM

http://www.codeproject.com/Questions/543002/Unableplustoplusgetpluspropertyplus-27PageRequestM

Thanks Fahad Mullaji

感谢法哈德·穆拉吉

回答by Chris Love

So I don't have a solution for you, but here is what I think is going on based on my experience with my Server compared to my local development machine. It looks like you are using the ASP.NET control toolkit, which was sort of deprecated a few years back and should be available as an open source project on Codeplex now. It is primarily driven from the server-side and I am betting it is doing some poor browser sniffing since that was a common thing to do back then. What it should do is feature detection.

所以我没有适合您的解决方案,但根据我在服务器上的经验与我的本地开发机器相比,这是我认为正在发生的事情。看起来您正在使用 ASP.NET 控件工具包,该工具包在几年前已被弃用,现在应该可以作为 Codeplex 上的开源项目使用。它主要是从服务器端驱动的,我敢打赌它正在做一些糟糕的浏览器嗅探,因为当时这是很常见的事情。它应该做的是特征检测。

So where does the problem come from? So my local dev machine reports IE 11 as majorVersion == 11. My server reports majorVersion as 7. So there really needs to be a patch to fix the server, but I am not sure if it exists yet. The other option is to go patch the control toolkit to NOT browser sniff and feature detect instead. That is a very daunting task to say the least.

那么问题从何而来呢?所以我的本地开发机器将 IE 11 报告为 MajorVersion == 11。我的服务器报告 MajorVersion 为 7。所以确实需要一个补丁来修复服务器,但我不确定它是否存在。另一种选择是修补控制工具包,而不是浏览器嗅探和功能检测。至少可以说,这是一项非常艰巨的任务。

Just 2 cents worth on the topic though. This is a real concern because I am guessing this issue might actually keep your company or client from actually updating their systems, which eventually will catch up to them and cause them major issues, like not upgrading XP machines by April is going to cause a lot of companies.

不过,这个话题只值 2 美分。这是一个真正的问题,因为我猜这个问题实际上可能会阻止您的公司或客户实际更新他们的系统,这最终会赶上他们并导致他们出现重大问题,例如在 4 月之前不升级 XP 机器会导致很多问题的公司。

Sorry I do not have a solution for you, but this is very interesting as I am doing research on issues that need to be resolved to help companies get off obsolete platforms like old IE & XP right now.

抱歉,我没有适合您的解决方案,但这很有趣,因为我正在研究需要解决的问题,以帮助公司摆脱过时的平台,例如旧的 IE 和 XP。

回答by Liran

The problem is with the userAgent string sent by IE 11 where Dot Net 4.0 frameworks or below do not recognize as Internet Explorer. You can fix this problem either by upgrading your server to Dot Net 4.5 or you can add add an ie.Browser file in your web application within the folder App_Browsers with the following entry

问题在于 IE 11 发送的 userAgent 字符串,其中 Dot Net 4.0 框架或更低版本无法识别为 Internet Explorer。您可以通过将服务器升级到 Dot Net 4.5 来解决此问题,也可以在 Web 应用程序中的 App_Browsers 文件夹中添加一个 ie.Browser 文件,并使用以下条目

<browser id="InternetExplorer" parentID="Mozilla">
    <identification>
        <userAgent match="Trident/(?'layoutVersion'[7-9]|0*[1-9]\d+)(\.\d+)?;(.*;)?\s*rv:(?'version'(?'major'\d+)(\.(?'minor'\d+)))" />
        <userAgent nonMatch="IEMobile" />
        <userAgent nonMatch="MSIE " />
    </identification>

    <capabilities>
        <capability name="browser"              value="InternetExplorer" />
        <capability name="version"              value="${version}" />
        <capability name="majorversion"         value="${major}" />
        <capability name="minorversion"         value="${minor}" />
        <capability name="layoutEngine"         value="Trident" />
        <capability name="layoutEngineVersion"  value="${layoutVersion}" />
        <capability name="type"                 value="InternetExplorer${major}" />
    </capabilities>
</browser>

回答by KyleUp

the references config file from Liran will work but only if Mozilla has javascript enabled. .Net 4.0 didn't have javascript enabled for Mozilla. This is from the default.browser file from a server with .Net 4.5:

来自 Liran 的引用配置文件将起作用,但前提是 Mozilla 启用了 javascript。.Net 4.0 没有为 Mozilla 启用 javascript。这是来自具有 .Net 4.5 的服务器的 default.browser 文件:

<browser id="Mozilla" parentID="Default">
    <identification>
        <userAgent match="Mozilla" />
    </identification>
    <capture>
    </capture>
    <capabilities>
        <capability name="javascript" value="true" />
  • then run aspnet_regbrowsers.exe because browser files don't actually do anything until you run that.
  • If you're using a App_Browsers folder in your project you'll also need to delete your temporary internet files (mine was in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files but your results may vary of course). You have to delete it because ASPNet needs to regenerate a dynamic DLL it generates from your App_Browsers/*.browser files.
  • 然后运行 ​​aspnet_regbrowsers.exe 因为浏览器文件在你运行它之前实际上不会做任何事情。
  • 如果您在项目中使用 App_Browsers 文件夹,您还需要删除临时 Internet 文件(我的位于 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files 但您的结果可能当然不同)。您必须删除它,因为 ASPNet 需要重新生成它从您的 App_Browsers/*.browser 文件生成的动态 DLL。

Of course the easiest way is just install .Net 4.5. This answer is only applicable to people who can't for some reason.

当然,最简单的方法就是安装 .Net 4.5。这个答案只适用于因某种原因不能的人。

回答by Fahad Mullaji

Finally found solution to this problem. I upgraded .NET version from 4.0 to 4.5. I don't know how it internally works.

终于找到了解决这个问题的方法。我将 .NET 版本从 4.0 升级到 4.5。我不知道它内部是如何工作的。

Thanks

谢谢

回答by user3024816

This seems to be an known issues as the framework is not able to detect IE 11 as Microsoft Internet Explorer. You can download the patch from following link to resolve the problem.

这似乎是一个已知问题,因为该框架无法将 IE 11 检测为 Microsoft Internet Explorer。您可以从以下链接下载补丁来解决问题。

Click here to Download patch from Microsoft site

单击此处从 Microsoft 站点下载补丁

Or following:

<head>
<meta http-equiv="X-UA-Compatible" content="IE=10" />
</head>