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 an ASP.Net web application project?

Here is 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 that will see moderate use within the organization. Thanks for answers.

+18
Jan 12 2018-12-12T00:
source share
2 answers

System.Environment.UserName returns the identifier under which the application pool is running on which your web application is hosted. If you use Windows authentication and impersonation, this will be the actual username, however, in all cases, you better use the information provided by the HTTP context. In any case, there is no performance.

+12
Jan 12 '12 at 20:30
source

Description

System.Web.HttpContext.Current.User.Identity.Name

Gets or sets the security information for the current HTTP request. (The name of the registered user on your website)

System.Environment.UserName

Gets the username that is currently registered with the Windows operating system.

Additional Information

+31
Jan 12 2018-12-12T00:
source



All Articles