tags:

views:

187

answers:

2

As I create user using built in asp.net sql tables and login controls, I would like to get to userid. How do I do that? Google is returning whole bunch of information but no where I could find an easy example to get UserID.

If user does exist, then I should get a userid, which I could store in my own custom tables for further user personal information management.

This whole membership and profile thing is very confusing to me. Google returned resuilts have all these pages with long explanation but it only confuses me. I can not even find the namespace in some of those dumb examples.

You can tell I am frustrated.

Please help !!!

A: 

You're looking for information on Forms Authentication.

The answer to your specific question is via HttpContext.Current.User. The Page class has a property named User which wraps HttpContext.

If HttpContext.Current.User.Identity.IsAuthenticated Then
    Dim userName As String = HttpContext.Current.User.Identity.Name
    ' ... 
End If
Ken Browning
+1  A: 

This will give you the MembershipUser for the current logged in user

MembershipUser currentUser = Membership.GetUser(True)

From that you would use the ProviderUserKey property to get provider specific identifier. This is an object, so, assuming SqlMembershipProvider you need to cast it to a GUID. You can then use that in your tables.

blowdart