asp.net-mvc IIS 上的 ASP.NET MVC3 和 Windows Auth 不断重定向到 /Account/Login

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5009565/
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-09-08 00:53:27  来源:igfitidea点击:

ASP.NET MVC3 and Windows Auth on IIS keeps redirecting to /Account/Login

asp.net-mvcasp.net-mvc-3iis-6windows-authenticationsharp-architecture

提问by Kevin Jensen

I'm running MVC3 and a windows auth web application. When I deploy to IIS6 it runs great until I hit a page that requires authentication. It then is auto-redirecting to /Account/Login when I have no trace of that in my application and my web.config is configured to windows auth.

我正在运行 MVC3 和一个 windows auth web 应用程序。当我部署到 IIS6 时,它运行良好,直到我点击需要身份验证的页面。然后,当我的应用程序中没有任何踪迹并且我的 web.config 被配置为 Windows 身份验证时,它会自动重定向到 /Account/Login。

Any ideas?

有任何想法吗?

Here is my entire web.config file: http://pastie.org/1568510

这是我的整个 web.config 文件:http: //pastie.org/1568510

回答by Liam

Check whether you have WebMatrix.Data.dlland/or WebMatrix.WebData.dlldeployed in the bin directory of your application. If they are there (and you know you don't use them) then try removing them and accessing a page that requires authentication.

检查您的应用程序的 bin 目录中是否部署了WebMatrix.Data.dll和/或WebMatrix.WebData.dll。如果它们在那里(并且您知道您不使用它们),则尝试删除它们并访问需要身份验证的页面。

回答by TN.

In RTM try to add to <appSettings>in Web.config:

在 RTM 中尝试添加到<appSettings>in Web.config

<add key="enableSimpleMembership" value="false" />

(Thx to Problem exclusively using Windows Authentication in ASP.NET MVC 3 Beta.)

(感谢在 ASP.NET MVC 3 Beta 中专门使用 Windows 身份验证的问题。)

回答by Dan Gardiner

Not sure if you still have the issue or not, but try adding

不确定您是否仍然有问题,但请尝试添加

<add key="autoFormsAuthentication" value="false" />

to your web.config under appSettings. According to hereand here, that should solve your problem.

到 appSettings 下的 web.config。根据herehere,这应该可以解决您的问题。

回答by WebMad

Try override WebMatrix.dll default for login url by adding this to your appSettings (web.config) :

尝试通过将其添加到您的 appSettings (web.config) 来覆盖登录 url 的 WebMatrix.dll 默认值:

<add key="loginUrl" value="~/Account/LogOn"/>

WebMatrix.dll set the login Url to /Account/Login, if this key isn't set in the config file... It works for me.

WebMatrix.dll 将登录 URL 设置为 /Account/Login,如果此键未在配置文件中设置...它对我有用。

回答by Ber'Zophus

I had the same issue in my MVC4 project, only my project has Anonymous Authentication disabled outright, so Windows Authentication is always required.

我在 MVC4 项目中遇到了同样的问题,只有我的项目完全禁用了匿名身份验证,因此始终需要 Windows 身份验证。

I have no WebMatrix.* in my bin folder, and adding the autoFormsAuthentication and enableSimpleMembership keys to appSettings didn't do it for me.

我的 bin 文件夹中没有 WebMatrix.*,并且将 autoFormsAuthentication 和 enableSimpleMembership 键添加到 appSettings 并没有为我做这件事。

Instead, I had to comment out the following:

相反,我不得不注释掉以下内容:

<authentication mode="Forms">
    <forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>

And replace it with this:

并将其替换为:

<authentication mode="Windows" />

That did the trick.

这就是诀窍。

回答by Jeffrey Cho

In RTM try to add to in Web.config:

在 RTM 中尝试在 Web.config 中添加:

<add key="enableSimpleMembership" value="false" />

The above post works. +1 Add this key beforeadding deployable dependencies.

上面的帖子有效。+1添加可部署依赖项之前添加此密钥。

回答by TeamDotNet

I was using nopCommerce 2.65 and had this issue.

我使用的是 nopCommerce 2.65 并且遇到了这个问题。

I did not have any of WebMatrix.Data.dll nor WebMatrix.WebData.dll deployed in the bin folder, but adding

我没有在 bin 文件夹中部署任何 WebMatrix.Data.dll 和 WebMatrix.WebData.dll,但是添加

<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false" />

in the web.config solved it.

在 web.config 中解决了它。

回答by davegeekgoliath

Another way to override "login.aspx url redirection problem with MVC + IIS 7"... by adding this to your appSettings (web.config) :

另一种覆盖“MVC + IIS 7 的 login.aspx url 重定向问题”的方法......通过将其添加到您的 appSettings (web.config) :

<authentication mode="Forms">
<!--<forms loginUrl="~/Account/Login" timeout="2880" />-->
<forms loginUrl="~/Home" timeout="2880" />
</authentication>

...This resolved the problem for me

...这为我解决了问题

回答by Akiv

I fixed it this way
1) Go ot IIS
2) Select your Project
3) Click on "Authentication"
4) Click on "Anonymous Authentication" > Edit > select "Application pool identity" instead of "Specific User".
5) Done.

我以这种方式修复它
1) 转到 IIS
2) 选择您的项目
3) 单击“身份验证”
4) 单击“匿名身​​份验证”> 编辑 > 选择“应用程序池标识”而不是“特定用户”。
5)完成。

回答by sourcx

Make sure that all the authentication settings in IIS are correct.

确保 IIS 中的所有身份验证设置都正确。

For me the application that redirected to /Account/Login was running within a site that Anonymous authentication enabled. After disabling this in the site and enabling it for the application (together with Windows authentication) it was ok.

对我来说,重定向到 /Account/Login 的应用程序正在启用匿名身份验证的站点中运行。在站点中禁用此功能并为应用程序启用它(与 Windows 身份验证一起)后,就可以了。