|
-
Apr 6th, 2004, 05:09 AM
#1
Thread Starter
Hyperactive Member
Context.User.Identity.Name is empty value
Dear ..
How to get the use login value after succssful login.
I am assigning Context.User.Identity.Name to the variable but the context.user has empty value.
can any body help me what settings need to done so that I will get Context.User.Identity.Name value.
Help is expected and appreciated..
Thanks & Regsrds
PPCC
-
Apr 6th, 2004, 07:09 AM
#2
Are you using formsauthentication?
if so user.identity.name should work no problem.
Try running
VB Code:
if user.Identity.IsAuthenticated then
'Do something here
end if
first to check that authCookie has been properly set.
Failing that could you post your login code?
-
Apr 6th, 2004, 06:51 PM
#3
PowerPoster
Try HttpContext.Current.User.Identity.Name
which is just what Fishcake said to do.
-
Apr 7th, 2004, 02:16 AM
#4
Thread Starter
Hyperactive Member
forms authentication
yes I am doing formsauthentication, now how to set authcookie.Is it auto set.
how context.user.identity.name relates with application_authenticateRequest event in golbal.asax .
reply..
PPCC
-
Apr 7th, 2004, 03:45 AM
#5
There's a couple of ways you can set the AuthCookie.
1.
VB Code:
FormsAuthentication.SetAuthCookie(intPlayerID, False)
Where intPlayerID is actually a string that uniquely identify's your user and true/false states wether the cookie is persistent.
2.
VB Code:
FormsAuthentication.RedirectFromLoginPage(intPlayerID, False)
This method can be used to redirect a user back to a page they were trying to visit before they were authenticated, same parameters as above.
Be warned that if you use the second method and directly enter the address of the login page you will simply keep getting taken back to it.
After either of these methods user.identity.name will hold the value of your user in my case intPlayerID.
As for application_authenticateRequest i've never actually used it but i'd guess it fires when a user tries to visit a page of your site that requires authentication (please tell me if i wrong), so you shouldn't need to worry about that for now.
-
Apr 7th, 2004, 07:53 AM
#6
Thread Starter
Hyperactive Member
form authentication
Great..
I have tried second option
i.e
.RedirectFromLoginPage("Id",false)
but after that Context.User.Identity.Name is getting empty.
can u please help me.
Thanks
PPCC
-
Apr 7th, 2004, 08:00 AM
#7
I'm not actually sure what difference context makes but i have simply always used "user.identity.name".
Other than that the only reason i can see for that being empty is if "id" is empty to start with.
-
Nov 9th, 2005, 03:50 PM
#8
Lively Member
Re: Context.User.Identity.Name is empty value
I am having the same problem, did you ever solve this?
-
Nov 9th, 2005, 05:31 PM
#9
Addicted Member
Re: Context.User.Identity.Name is empty value
Had the same issue.. used all of the above... ended up making my own cookie with encryption for the username etc
Couldn't use the session cos i think my hosting hasn't got their webfarm working propery.. session gets lost sometimes and appears again
If the facts don't fit the theory, change the facts. --Albert Einstein
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|