It may be duplication question but I did not found any solution from other post.
I am using Windows authentication, when I am building application on local system its working fine but when I am deploying the application on IIS HttpContext.Current.User.Identity.Name is returning null. I have disable eveything except Windows authentication on authentication setting.
var strUserName = HttpContext.Current.User.Identity.Name == "" ? System.Security.Principal.WindowsIdentity.GetCurrent().Name : HttpContext.Current.User.Identity.Name;
I am getting strUserName null.
<authentication mode="Windows">
</authentication>
<identity impersonate="true"/>
I try to divide the line and write the code to check what is exactly returing...
HttpContext.Current.User.Identity.Name is returning null
System.Security.Principal.WindowsIdentity.GetCurrent().Name is returning NT AUTHORITY\IUSR when impersonate is true
System.Security.Principal.WindowsIdentity.GetCurrent().Name is returning IIS APPPOOL\ApplicationPoolName when impersonate is false
below few link I have checked