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

谁说胖子不能爱 提交于 2019-12-02 08:52:05

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
}

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.

Matt

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?

Kedar Godkhindi

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

  public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            //ConfigureAuth(app);
        }
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!