Get the username in Forms authentication Get the username in Forms authentication asp.net asp.net

Get the username in Forms authentication


To get the UserName of the authenticated user:

HttpContext.Current.User.Identity.Name;


That's exactly how I do it, I think there might be something wrong with your setup? For example, are you actually logged into the site while your debugging? If not, you need to in order to get a value.


It may depend on when in the lifecycle you are asking.

If you handle BeginRequest() then there will not yet be any authentication information. Whereas if you handle EndRequest() there will.