MVC 4 application goes to login page first using Windows auth when run

前端 未结 4 2106
我在风中等你
我在风中等你 2021-01-26 12:14

I am currently developing a project that will use Windows authentication to authorize users and set their specific permissions. However, every time I run the program to test, t

相关标签:
4条回答
  • 2021-01-26 12:33

    I would suggest removing the FormsAuthentication module if you're not planning go to use cookie based authentication.

    <system.webServer>
      <modules>
        <remove name="FormsAuthenticationModule" />
      </modules>
    </system.webServer>
    

    Then it won't redirect to the default anymore.

    Also, if you're not using SimpleMembership, go ahead and strip out all the membership code from you Account controller, and uninstall the various packages related to it via nuget. This would include the WebMatrix and the oauth and openid packages.

    0 讨论(0)
  • 2021-01-26 12:46

    Is there extra controls in the controller that would specify a user has to be logged in before accessing any pages?

    Example

    [Authorize(Roles = "admin")] // this can even be declared at the top of the controller and the controllers will force all to login.
    public ActionResult TheController()
    {
      //TODO
    }
    
    0 讨论(0)
  • 2021-01-26 12:46

    As it turns out, when creating an MVC ASP.NET application, two web.config files are generated. My changes were going into the wrong web.config file (the one under the views folder), rather than the main one in the application. By applying the changes in my original question to this other config file, the application works as intended.

    For more information on the two web.config files, see this SO question: Why does .NET generate two web.config files in an MVC asp.net application?

    0 讨论(0)
  • 2021-01-26 12:51

    You can comment the code to configure the AppBuilder in StartUp.cs

      public partial class Startup
        {
            public void Configuration(IAppBuilder app)
            {
                //ConfigureAuth(app);
            }
        }
    
    0 讨论(0)
提交回复
热议问题