0

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
2
  • 1
    Are you hosting this with IISExpress? Have you turn off Anonymous Authentication. Commented Feb 13, 2017 at 20:55
  • yes hosted on IIS and Anonymous Authentication is off Commented Feb 15, 2017 at 16:24

2 Answers 2

1

Have you entered like this is Web.Config

<system.web>
   <authentication mode="Windows"/>
</system.web>
Sign up to request clarification or add additional context in comments.

Comments

1

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

1 Comment

To open Project Properties Window in VS 2019: select your project in Solution Explorer and press F4 or go to View -> Properties Windows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.