ASP.Net MVC身份无限重定向循环 [英] ASP.Net MVC identity infinite redirect loop

查看:244
本文介绍了ASP.Net MVC身份无限重定向循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.Net MVC5应用程序,根据ASP.Net Identity 2.0.0,使用开箱即用"身份模板.我需要对其进行升级,以使用最新的ASP.Net MVC模板中的更新代码,即SignInManager类的使用.

我在原始应用程序中的代码和最新生成的模板之间进行了A | B比较,并移植了所有我能看到的不同之处.

但是,我怀疑是与OWIN有关,这是一个奇怪的错误.当我尝试登录或注册时,它会触发重定向循环,最终会由于安全查询而使应用程序崩溃,因为URL查询字符串已串联成死机.


URL是: 解决方案

已解决...罪魁祸首是我的Unity DI配置.

我深入研究,发现每个重定向上递归引发的错误,它提示AccountController依赖关系未实例化.去年我有一个类似的问题团结容器尝试解析未注册的类型,引发错误,因此我进一步研究了更改后的依赖项.

按照向Unity注册IAuthenticationManager的建议答案解决了该问题.

感谢以下建议:SSL/HTTPS/过滤器,对这些问题进行了调查,使我发现了例外情况.

I have an ASP.Net MVC5 application, using the Identity "out of the box" template, as per ASP.Net Identity 2.0.0. I need to upgrade it to use the newer code that is in the latest ASP.Net MVC template, namely the use of the SignInManager class.

I have done some A|B comparisons between the code in my original app and the template generated in the latest, and ported over all that I could see what different.

However, I'm getting an odd error, I suspect OWIN related. When I try and Login or Register, it triggers a Redirect loop that eventually crashes the app with a security warning as the URL Query string has concatenated itself to death.


The URL is : https://localhost:44302/Account/Login?ReturnUrl=%2FAccount%2FLogin%3FReturnUrl%3D%252FAccount%252FLogin%253FReturnUrl%253D%25252FAccount%25252FLogin%25253FReturnUrl%25253D%2525252FAccount%2525252FLogin%2525253FReturnUrl%2525253D%252525252FAccount%252525252FLogin%252525253FReturnUrl%252525253D%25252525252FAccount%25252525252FLogin%25252525253FReturnUrl%25252525253D%2525252525252FAccount%2525252525252FLogin%2525252525253FReturnUrl%2525252525253D%252525252525252FAccount%252525252525252FLogin%252525252525253FReturnUrl%252525252525253D%25252525252525252FAccount%25252525252525252FLogin%25252525252525253FReturnUrl%25252525252525253D%2525252525252525252FAccount%2525252525252525252FLogin%2525252525252525253FReturnUrl%2525252525252525253D%252525252525252525252FAccount%252525252525252525252FLogin%252525252525252525253FReturnUrl%252525252525252525253D%25252525252525252525252FAccount%25252525252525252525252FLogin%25252525252525252525253FReturnUrl%25252525252525252525253D%2525252525252525252525252FAccount%2525252525252525252525252FLogin%2525252525252525252525253FReturnUrl%2525252525252525252525253D%252525252525252525252525252FAccount%252525252525252525252525252FLogin%252525252525252525252525253FReturnUrl%252525252525252525252525253D%25252525252525252525252525252FAccount%25252525252525252525252525252FLogin%25252525252525252525252525253FReturnUrl%25252525252525252525252525253D%2525252525252525252525252525252FAccount%2525252525252525252525252525252FLogin%2525252525252525252525252525253FReturnUrl%2525252525252525252525252525253D%252525252525252525252525252525252FAccount%252525252525252525252525252525252FLogin%252525252525252525252525252525253FReturnUrl%252525252525252525252525252525253D%25252525252525252525252525252525252FAccount%25252525252525252525252525252525252FLogin%25252525252525252525252525252525253FReturnUrl%25252525252525252525252525252525253D%2525252525252525252525252525252525252FAccount%2525252525252525252525252525252525252FLogin%2525252525252525252525252525252525253FReturnUrl%2525252525252525252525252525252525253D%252525252525252525252525252525252525252FAccount%252525252525252525252525252525252525252FLogin

Detailed Error Information:

Module    RequestFilteringModule

Notification    BeginRequest

Handler    ExtensionlessUrlHandler-Integrated-4.0

Error Code    0x00000000


I've used the exact same settings when referring to ReturnUrl in all methods.

For the most part, my applications' original AccountController and related security code was untouched from the original template. My newer sample application runs fine on my local machine, so I’m not sure where the differences are.

I've seen posts suggesting that IIS Express configuration is to blame, but I've followed the cleanup advice, and also published to an Azure site with the same result.

I've been spending a lot of time trying to resolve this and haven't had any success so I thought I'd put it out there for some advice… thanks in advance for any & all help. Please let me know if you need to see more code.

解决方案

Resolved... turns out the culprit was my Unity DI configuration.

I drilled deep to find the errors getting recursively thrown on each redirect, and it suggested the AccountController dependencies weren't being instantiated. I had a similiar issue last year Unity Container trying to resolve non registered type, throwing error , and so I looked further into the changed dependencies.

Following the suggested answer at Register IAuthenticationManager with Unity resolved the issue.

Thanks for the suggestions re: SSL / HTTPS / Filters, investigating these led me to the exceptions.

这篇关于ASP.Net MVC身份无限重定向循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆