Windows身份验证不是在ASP.NET MVC 5 web应用程序的工作 [英] Windows Authentication not working in ASP.NET MVC 5 web app
问题描述
我有一个ASP.NET MVC应用5和我试图启用Windows身份验证。开发机是在Windows Server 2008 R2中,IIS防爆preSS 8.0时,Visual Studio 2013和放大器; .NET框架4.5。
I have an ASP.NET MVC 5 app and am trying to enable Windows Authentication. The development machine is Windows Server 2008 R2, IIS Express 8.0, Visual Studio 2013 & .NET Framework 4.5.
我得到一个404 Not Found错误当过我浏览的应用程序。该应用程序进入是 HTTP重定向循环://本地主机:63455 /帐号/登录RETURNURL =%2F 。最终, RETURNURL
结束是非常大的,因为它被附加到每个重定向。
I get a 404 Not Found error when ever I browse the app. The app enters a redirect loop with http://localhost:63455/Account/Login?ReturnUrl=%2F. Eventually the ReturnUrl
ends up being very large as it gets appended to with each redirect.
我的web.config文件看起来是这样的:
My web.config looks like this:
<system.web>
<authentication mode="Windows"/>
</system.web>
我试过设置在匿名身份验证和 Windows身份验证在开发服务器的属性设置。
I've tried setting the Anonymous Authentication and Windows Authentication settings on the Development Server properties.
我也尝试添加以下的appSettings
:
<add key="autoFormsAuthentication" value="false"/>
<add key="enableSimpleMembership" value="false"/>
我如何获得Windows身份验证工作正常?
推荐答案
在 Startup.Auth.cs $ C $的
ConfigureAuth
方法C>包含以下code这需要被删除的 Windows身份验证
The ConfigureAuth
method in Startup.Auth.cs
contained the following code which needed to be removed for Windows Authentication.
在code用于表单验证是 OWIN
// Enable the application to use a cookie to store information for the signed in user
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login")
});
// Use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
这篇关于Windows身份验证不是在ASP.NET MVC 5 web应用程序的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!