简体   繁体   中英

ASP.NET Membership + User Creation configuration

I'm writing a small website in ASP.NET C#.

I've already made a database which will receive the user data and various other things.

Now I want to register users. I've found the MembershipUser and MembershipCreateStatus class and enum to be often used for this.

However, even though my database is seen in the Server Explorer of Visual Studio, I can't seem to link the User-creation to that database.

What I want is when I do this:

MembershipUser newUser = Membership.CreateUser(username.Text, password.Text, email.Text);

It ends up in the database and table of my choice. I can't find how to configure this.

The ASP.Net membership provider uses its own tables/stored procedures for storing user data.

http://msdn.microsoft.com/en-us/library/yh26yfzy.aspx

You can use your own table for profile info (that is, non-authentication information) using either the ProfileProvider or by using the guid assigned by in the aspnet_Users table as a key for your own table and retrieving the profile record after authentication occurs.

From the Visual Studio command prompt run the following:

aspnet_regsql -S [my server, eg: (local)\\SQLEXPRESS] -E -A all -d [my database]

This will attach the ASP.NET user required stored procedures and tables to your database so that the built in Membership and Role Providers can actualy work.

use the WAT tool in VS to create your initial users if you need so you can test right away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM