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


What is the difference between System.Web.HttpContext.Current.User.Identity.Name and System.Environment.UserName in the context of a ASP.Net Web Application Project?

Here's the code of what I'm trying to do:

Database myDB = DatabaseFactory.CreateDatabase();
bool IsAuthUser = myDB.ExecuteScalar("procIsAuthorizedUser", System.Environment.UserName);

If they are functionally identical, which is better in terms of performance?

This is a C# 4.0/ASP.Net web application which will see moderate usage internally in the organization. Thank you for the answers.

Best Solution



Gets or sets security information for the current HTTP request. (The Name of the Logged in user on your Website)


Gets the user name of the person who is currently logged on to the Windows operating system.

More Information