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.