ZCoder
ZCoder

Reputation: 2339

Windows authentication not working asp.net mvc showing null

Web.Config windows authentication showing null username

My WebConfig authentication is enable

C# code I tried

WindowsIdentity.GetCurrent(); // showing null
System.Security.Principal.WindowsIdentity.GetCurrent().Name  // showing null
System.Security.Principal.WindowsIdentity.GetCurrent().Name;// showing null
Request.ServerVariables["LOGON_USER"] // showing null
Request.ServerVariables["REMOTE_USER"] // showing null

Upvotes: 0

Views: 799

Answers (2)

Tannheuser
Tannheuser

Reputation: 416

In my case I checked Project properties window.

Anonymous Authentication was set Enabled and Windows Authentication - to Disabled. I changed these values and it helped me.

enter image description here

Upvotes: 1

Zahid Mustafa
Zahid Mustafa

Reputation: 195

Have you entered like this is Web.Config

<system.web>
   <authentication mode="Windows"/>
</system.web>

Upvotes: 1

Related Questions