我们正在运行IIS7并启用了Windows身份验证。其他一切都被禁用了。当我们转到页面时,我们不会提示我们进行Windows登录,但是会被重定向到默认的表单身份验证登录页面(帐户/登录?ReturnUrl =%2f)。
有什么想法吗?感谢。
答案 0 :(得分:6)
以及:
<authentication mode="Windows"></authentication>
<authorization>
<allow users="*"/>
</authorization>
您也可能需要这两个appSettings
:
<appSettings>
<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false"/>
</appSettings>
请参阅MVC3发行说明中的this answer on SO和Known Issues。
答案 1 :(得分:4)
如果有人到目前为止并且其他答案尚未解决问题,请检查项目的App_Code文件夹中名为Startup.Auth.cs的文件。在我的情况下,下面的代码块是活动的,导致重定向到我不想使用的登录页面。
// Enable the application to use a cookie to store information for the signed in user
// and also store information about a user logging in with a third party login provider.
// This is required if your application allows users to login
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login")
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
答案 2 :(得分:3)
您是否确保在asp.net应用程序中启用了Windows身份验证而不是表单?
确保web.config文件设置为:
<authentication mode="Windows"/>
<authorization>
<allow users="*"/>
</authorization>
您的应用程序中的身份验证模式可能仍设置为表单身份验证,这就是表单功能正在发挥作用的原因。
如果您的应用程序中有嵌套文件夹,也不要忘记调整任何嵌套web.config文件。
答案 3 :(得分:0)
实际上这个SO问题为我解决了 - 我还没有尝试过上述解决方案:
ASP.NET MVC3 and Windows Auth on IIS keeps redirecting to /Account/Login
只是检查你的bin目录是否包含以下内容: WebMatrix.Data.dll 和/或 WebMatrix.WebData.dll ,如果是 - 删除它们!
然后确保他们从未通过从项目的参考列表中删除它们再次发布到bin中。
答案 4 :(得分:0)