Question : Get username and role c#.net

I have a login file that created with vs 2008:
   
   

and a logout that simply use FormsAuthentication.SignOut();
authorization and roleManager are configured through web.cofig and is set to form auth with allowed roles for folders using .net provider which works fine.

My question is simple I think: I need to finid out the username and role based on login and put it them in session for other pages to retrieve? Also should the session put in the global.asax file? thanks

Answer : Get username and role c#.net

You can get the username like this:

string UserName = Login1.UserName.ToString();
Session["UserName"] = UserName;

Use OnLoggingIn or  OnLoggedIn

to use in other pages

string UserName = (string)Session["UserName"];
and based on the username query other data.

Random Solutions  
 
programming4us programming4us