>Hi Viv,
>
>That worked but as you but it does hit the database again. I guess I could store the value in a session variable so the hit would only happen after the log in. I need this value so I can provide the data that only user owns.
>
>The next question is how to cast the string back to a guid or should I just store the guid directly to the session variable if I can?
>
>Update: I should have tried google first.
>
>Guid guUserid = new Guid(curuserid);
Session variables are stored as objects so why not just store it as a Guid:
Session["UserId"]=GetTheUsersGuid();
Guid UserId = (Guid)Session["UserId"];
but see my suggestion in your other post re: using a custom object....
>
>>I'm rusty on this so had to look it up (and I'm still not sure it's the best solution but):
>>You can use Membership.GetUser(Page.Identity.Name) to get the relevant MembershipUser and it's ProviderUserKey property will give you the Id. However I think this, in itself, will cause a hit on the DB so I guess you should do it on the initial authentication and store it as a session variable for future use ?
>>This also begs the question of what you want to do with it once it's stored ?
>>HTH,
>>Viv
>>
>>>Sorry for about that. I am using the built in Membership controls. It works quite well except I need to get the user ID that is stored in the aspnet_Membership table. I found the user name in Page.User.Identity.Name. I really don't want to make another trip to the database just to get the userid.
>>>
>>>>>Hi All
>>>>>
>>>>>I have my web site running and logging in. The login controls seems to be this big black box and I can't seem to find much documentation on how the work. I seems hard to find anything in the help. Now I need to know where to get the user id for each hit after the user logs in?
>>>>
>>>>You don't mention what authentication you are using and I'm not sure what you mean by the 'user id' but Page.User should provide an IPrincipal so maybe something like Page.User.Identity.Name........