Search code examples
asp.net-mvcasp.net-mvc-4windows-authentication

MVC4: Windows Authentication on first Controller/Action


I have set a global Authorize for this Windows-Integrated MVC4 web site:

    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
        filters.Add(new System.Web.Mvc.AuthorizeAttribute());
    }

The default controller is a simple welcome page, and IE8 asks for the username password. The problem is that regardless of what username/password use to log in, it fails after 4 attempts with HTTP Error 401.0 - Unauthorized.

Only if I make the first default controller set to [AllowAnonymous] does it let me in so that when I navigate to another action the prompted username/password it works.

It's like the web site has to "warm up?"

Question: How do I set the default controller/action to ask for and accept a username/ password?

enter image description here


Solution

  • You can add [Authorize] as the attribute for the welcome page. That should not prompt for a username/password as long as the user has valid network credentials.