Asp.net-Mvc-5
Windows 身份驗證在 ASP.NET MVC 5 Web 應用程序中不起作用
我有一個 ASP.NET MVC 5 應用程序並正在嘗試啟用 Windows 身份驗證。開發機器是 Windows Server 2008 R2、IIS Express 8.0、Visual Studio 2013 & .NET Framework 4.5。
每當我瀏覽應用程序時,都會收到 404 Not Found 錯誤。該應用程序使用http://localhost:63455/Account/Login?ReturnUrl=%2F進入重定向循環。最終結果
ReturnUrl會變得非常大,因為它會附加到每個重定向中。我的 web.config 看起來像這樣:
<system.web> <authentication mode="Windows"/> </system.web>我嘗試在開發伺服器屬性上設置匿名身份驗證和Windows 身份驗證設置。
我還嘗試添加以下內容
appSettings:<add key="autoFormsAuthentication" value="false"/> <add key="enableSimpleMembership" value="false"/>如何讓 Windows 身份驗證正常工作?
中的
ConfigureAuth方法Startup.Auth.cs包含以下程式碼,需要為Windows Authentication刪除這些程式碼。該程式碼用於使用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);
