Search code examples
c#asp.nethttpcontextwindows-identity

Cant get HttpContext.Current.User.Identity to return values


This project authenticates with System.Security.Principal.WindowsIdentity

I had a look at this: Can't get HttpContext.Current.User.Identity to work in my WebMatrix project

        IIdentity WinId = HttpContext.Current.User.Identity;//returns no data
        WindowsIdentity wi = (WindowsIdentity)WinId;

I have disabled anonymous in my Web.config

http://forums.asp.net/t/1901573.aspx?System+web+HttpContext+Current+User+Identity+Name+returns+Empty+string

  <authorization>
    <deny users="?" />
  </authorization> 

The wierd part is I have another project that uses the same code and has has the same .config but works,


Solution

  • Have you wrote this in your web config ??

    <authentication mode="Windows"/>
    

    and please just take a look this

    System.Web.HttpContext.Current.User.Identity.Name Vs System.Environment.UserName in ASP.NET