Getting logged on username
-
My site uses forms authentication (login control etc) to grant users access to the site. Is there a way to programatically get their username once they have logged in ? Thanks
Yes.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
Yes.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
It has been a long time since I last worked with this stuff, but you can try the Page.User.Identity.Name property, or see if you can get what you need by using the Membership.GetUser()[^] method.
Jon Sagara Once again, the conservative sandwich-heavy portfolio pays off for the hungry investor! *slurp* Oh, I'm ruined! -- Dr. Zoidberg .NET Blog | Personal Blog | Articles
-
My site uses forms authentication (login control etc) to grant users access to the site. Is there a way to programatically get their username once they have logged in ? Thanks
Yes, You can do it. There are various method available but the simplest way is to use 'cookies':), like this, ' on "Login.aspx.vb" page Dim uname As String = Login1.UserName Dim pwd As String = Login1.Password e.Authenticated= FormsAuthentication.Authenticate(uname,pwd) If FormsAuthentication.Authenticate(uname, pwd) Then FormsAuthentication.RedirectFromLoginPage(uname, True) Response.Cookies("CokieLogin").Value = uname Else Login1.FailureText = "Either User Name or Password is wrong." End If 'On "Default.aspx.vb" page Dim UserName As String = UCase(Request.Cookies("CokieLogin").Value) 'here we expire the cookies Response.Cookies("CokieLogin").Expires = System.DateTime.Now()
prabhakar