Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where to get the loged in user ID
Message
From
04/07/2010 12:32:50
 
 
To
04/07/2010 12:07:12
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, United States
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 4.0
Miscellaneous
Thread ID:
01471353
Message ID:
01471358
Views:
53
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........
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform