Wednesday, June 24, 2009

Authenticated User Information

So you have used the built-in ASP.NET Login controls (Login, LoginView, etc). Now what if you want to get at the authenticated user information in code?

Access it through the HttpContext.Current.User property.

Examples:
// Get the user's name
string userName = HttpContext.Current.User.Identity.Name;

More Info: MSDN: HttpContext.Current.User