Membership - Getting user id

M

mazdotnet

Hi,

I like to grab the user id of the currently added user. However, I
can't find a property that would do it.

MembershipUser newUser = Membership.CreateUser(tbxUsername.Text,
tbxPassword.Text,

tbxEmail.Text, "empty",
"empty",
true, out status);

I need something that would give me the newUser.UserID (database user
id)

Also, I had to use "empty", "empty" for the password question. If I
leave it empty, it says that password question not valid. Any way
around this?

Thanks
Maz
 
M

Mark Fitzpatrick

As far as the id goes, I can answer that one (not the password question
though).

What you want is the ProviderUserKey property of the MembershipUser object.
The ProviderUserKey returns an object and it's your responsibility to deal
with it appropriately. In the case of using SQL Server as a membership
store, it will return a GUID so you need to make sure it's cast to that in
order to access it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top