[英]Login ReturnUrl in ASP.NET WebForms causing JavaScript critical error when using IE11
I am developing ASP.NET Web Forms application using Visual Studio 2012, which utilizes bundling and SignalR. 我正在使用Visual Studio 2012开发ASP.NET Web Forms应用程序,该应用程序利用捆绑和SignalR。
I put this in my web.config: 我把它放在我的web.config中:
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" defaultUrl="~/Views/Portfolio" timeout="2880" />
</authentication>
<authorization>
<deny users ="?" />
<allow users = "*" />
</authorization>
When I hit F5 I get this kind of error: 当我按F5时,会出现这种错误:
JavaScript critical error at line 3, column 1 in http://localhost:6169/Account/Login?ReturnUrl=/bundles/WebFormsJs?v=AAyiAYwMfvmwjNSBfIMrBAqfU5exDukMVhrRuZ-PDU01&v=AAyiAYwMfvmwjNSBfIMrBAqfU5exDukMVhrRuZ-PDU01
SCRIPT1002: Syntax error
then followed by this: 然后是这个:
JavaScript critical error at line 3, column 1 in http://localhost:6169/Account/Login?ReturnUrl=/signalr/hubs
SCRIPT1002: Syntax error
I am using IE11 and these kind of errors didn't happen when using Firefox or Chrome. 我正在使用IE11,使用Firefox或Chrome时没有发生这些错误。 Please help?
请帮忙? Thanks
谢谢
Typically you cannot bundle dynamically generated JavaScript such as /signalr/hubs. 通常,您不能捆绑动态生成的JavaScript,例如/ signalr / hubs。
If you want to bundle the /signalr/hubs script (aka the SignalR JS hub proxy), you need to generate the script before deployment . 如果要捆绑/ signalr / hubs脚本(也称为SignalR JS集线器代理),则需要在部署之前生成脚本 。 This will give you a static JS file that you can bundle.
这将为您提供一个可以捆绑的静态JS文件。
The solution put forward by Halter73 worked for me, initially. Halter73提出的解决方案最初对我有用。 I was getting similar errors in IE11 and specifically noticed the "ReturnUrl=/signalr/hubs" in the URL.
我在IE11中遇到类似的错误,并特别注意到URL中的“ ReturnUrl = / signalr / hubs”。 However, I found some regression issues with the static proxy (both a chat and a users online widget broke) and so I rolled it back to using the default dynamically generated proxy.
但是,我发现静态代理存在一些回归问题(聊天和用户在线小部件都中断了),因此我将其回滚到使用默认的动态生成的代理。
So after doing that, I was back to the same error and I returned here and re-read the OP's original post and his own reply very carefully and realized it might be an issue with the authorization settings in my web.config, of which there were none for signalr/hubs. 因此,执行完此操作后,我又回到了相同的错误,然后返回此处,非常仔细地重新阅读了OP的原始帖子和他自己的回复,并意识到这可能与我的web.config中的授权设置有关。没有信号器/集线器。 Like the OP I also deny auth from various areas of my site so I needed to explicitly allow access to signalr/hubs so I simply added this to fix my issue:
像OP一样,我也拒绝站点各个区域的身份验证,因此我需要明确允许访问signalr / hub,因此我只添加了此内容即可解决我的问题:
<location path="signalr/hubs">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.