Are you saying that you want to save the username in the session, and not the user key from the membership database?
I had the same problem, you cannot get it from Membership objects. You need to save it when the user logs in. If you use the asp: Login control, you can add it to the repository using the OnLoggedIn event:
protected void OnLoggedIn(object sender, EventArgs e)
{
Session["username"] = Login1.UserName;
}
source
share