To retrieve a current username of a login user is pretty simple in ASP.Net. Firstly you need to use the framework object of Membership In System.Net.Security.
Please see below quick code snippet on how to get the current username, if the user has not login on the site, it will return an error message.
private string GetCurrentUsername() { System.Web.Security.MembershipUser objCurrentUser = System.Web.Security.Membership.GetUser(); if (objCurrentUser != null) { return objCurrentUser.UserName; } else { return "Error: user is not login on the site"; } }