0

I have an existing asp.net site that I want to modify to use Windows authentication (It is on a local intranet.)

I have modified the web.config file to use Windows Auth:

<configuration>
 <system.web>
  <authentication mode="Windows"/>
  <authorization>
  <deny users="?"/>
 </authorization>
 <compilation debug="true"/>
</system.web>

The error message that I get is:

401.2.: Unauthorized: Logon failed due to server configuration.

If I remove: <deny users="?"/> Then the page is shown. However this code shows that although the User is not null, the user is not logged in:

    protected void Page_Load(object sender, EventArgs e)
    {
        var userName = HttpContext.Current.User.Identity.Name;
    }

What I have tried:

In Visual Studio, if I create a new MVC App, and select "Windows Authentication" it works as expected, and the user is logged in with the domain name.

Reducing the project to just the web.config and a single aspx page still works. But when I try to use the same exact web.config in an existing project (Or a new empty project) I get the same error.

So there must be some other setting somewhere that needs to be set, but I cannot determine what it is.

Greg Gum
  • 33,478
  • 39
  • 162
  • 233

1 Answers1

1

I found the answer to this here

In Visual Studio, select the Project in the Solution Explorer, then press F4 to view the project properties. Note: These properties are on a side window (typically) not the main (center) window.

Set: 1) Windows Authentication to Enabled and 2) Anonymous Authentication to Disabled.

Paul Ratazzi
  • 6,289
  • 3
  • 38
  • 50
Greg Gum
  • 33,478
  • 39
  • 162
  • 233
  • This is a better answer: http://stackoverflow.com/questions/17043140/windows-authentication-doesnt-works-when-i-run-project-from-visual-studio – Greg Gum Jun 12 '14 at 14:05