A set of technologies in .NET for building web applications and web services. Miscellaneous topics that do not fit into specific categories.
Hi @Madadi, Shravani ,
Thanks for reaching out.
If User and IPrincipal are coming back as null in your .NET Framework 4.8.1 app hosted in Internet Information Services, it usually means the Windows identity isn’t flowing from IIS into ASP.NET, even if Windows Authentication looks enabled.
I recommend checking out the following:
- Disable Anonymous Authentication in IIS: Go to your site -> Authentication -> make sure:
- Windows Authentication = Enabled
- Anonymous Authentication = Disabled If Anonymous is still enabled, IIS may allow the request through without attaching a Windows identity, which results in
Userbeing null.
- Confirm web.config is set to Windows auth: Make sure you have:
If it’s set to<authentication mode="Windows" />Formsor anything else, ASP.NET won’t populateUsercorrectly. - Check Application Pool pipeline mode: In IIS -> Application Pool -> Advanced Settings:
- Ensure Integrated pipeline mode is selected. Windows Authentication behaves more reliably in Integrated mode.
- Verify the browser is sending credentials: If you’re accessing the site via IP address or a non-intranet hostname, the browser may not send Windows credentials automatically. Try accessing via:
or the machine name, and ensure the site is treated as a Local Intranet zone.http://localhost - Test what IIS is actually seeing: Add a quick test:
If this is empty, IIS never attached the identity, meaning the issue is configuration-level, not code-level.var name = HttpContext.Current?.User?.Identity?.Name;
Please take the above steps as a reference checklist to help narrow down where the identity might be getting lost in your specific setup. The exact adjustment may vary slightly depending on your environment, but this should give you a direction for investigation.
Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.