Windows Authentication not working in ASP.NET MVC 5 web app

前端 未结 2 919
遇见更好的自我
遇见更好的自我 2021-02-07 12:18

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 Fra

相关标签:
2条回答
  • 2021-02-07 13:00

    The ConfigureAuth method in Startup.Auth.cs contained the following code which needed to be removed for Windows Authentication.

    The code is used for Forms Authentication with 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);
    
    0 讨论(0)
  • 2021-02-07 13:15

    Just a heads up. You don't HAVE to remove cookie authentication entirely, although i did remove the externalsignincookie. Take a look at my project at https://github.com/vishnu4/AspNetMVC5WinAuth where I'm using OWIN and MVC5 to use windows authentication. Hopefully this helps anyone else trying to get it to work.

    0 讨论(0)
提交回复
热议问题