How to get user ID for newly registered user in ASP.Net CreateUserWizard?
I have a page that allows new users to register using the create user wizard. Immediately after creating the user, I would like to insert a row in the customer information table using the new user ID and email address.
I tried putting some code in CreateUserWizard1_CreatedUser to get the user id. But, from what I learned, the user is created at this stage; but the user is not logged in at this point. I get an error message ...
"NullReferenceException" is handled by user code. The object is not set to an instance of the object. "
If I set a breakpoint during debugging, I see that customerId is null.
From what I read on MSDN, the CreatedUser event ... "Occurs after the membership provider has created a new website user account."
I want to add a row to the customer details table before changing the User Creation Wizard to display the Continue button. At this point, the user can go to other pages or close the application.
Is there any other event after CreateUser where I can put some code? I see that there is an Unload event. http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.createuserwizard_events%28v=vs.110%29.aspx
Is there any way to register a user in the CreatedUser event to get the user ID?
Here is my code on the registry page that does not work. The error occurs in the line of code: "string customerId ="
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) {
...
}
source share