开发者

Why CreateUserWizard Control automatically adds the ASPNETDB.MDF database?

开发者 https://www.devze.com 2023-03-22 16:08 出处:网络
I only want to use CreateUserWizard Control to collect information from the user and insert into my custom database. I don\'t want to use Asp.Net Membership .

I only want to use CreateUserWizard Control to collect information from the user and insert into my custom database. I don't want to use Asp.Net Membership .

When I add this setting to the web.config <membership> <providers> <clear /> </providers> </membership>

The following error comes Default Membership Provider must be specified.

And when I remove this setting from the web.config. The page runs successfully BUT createUserWizard Control automatically adds the ASPNETDB.MDF database to the App_Data folder.

Question: 开发者_Go百科Can we use CreateUserWizard with custom database with out using ASPNETDB or asp.net membership ?


The CreateUserWizard control provides the user interface for the MembershipProvider object that communicates with your Web site's user data store to create new user accounts in the data store. The CreateUserWizard relies on the MembershipProvider to create the user and disable them if necessary (cf. msdn).

So you have to use a Membership Provider if you use the CreateUserWizard.

If you do not want to use the standard Membership Provider, you should consider creating a Custom Membership Provider.

But from your question it is not clear why you do not want to use the standard Membership. May be it is worth to look at the possibility to include the standard Membership schema into your own database and save yourself a lot of work (not to mention possible security issues etc.) using the authorisation functionality which is already implemented in asp.net. Here you can find how to put the Membership schema into the same database as the application data.

UPDATE:

If you still want to prevent the CreateUserWizard's CreateUser step from creating the user by means of Membership Provider, you can try to handle the CreatingUser event and set its LoginCancelEventArgs.Cancel property to true.

Example code:

protected void RegisterUser_CreatingUser(object sender, LoginCancelEventArgs e) 
{
 e.Cancel = true; 
} 

Then in order to move to the next page in the wizard you need to handle NextButtonClick event:

  1. Add e.Cancel = False;
  2. Add CreateUserWizard.ActiveStepIndex = (your next wizard step index);

After that you will need to create the user manually, e.g. in FinishButtonClick event handler.

Hope it helps.


I have had the same problem that i wanted the membership tables, views and stored procedure to be on my database, so you have to run the following command using the visual studio command prompt and write the following command line:

Aspnet_regsql.exe -W

Please notice that it is a case sensitive then a wizard will appear to allow you create the membership tables, views and stored procedures

Why CreateUserWizard Control automatically adds the ASPNETDB.MDF database?

Then you will need to update you web.config file to update the connection string that points to the .mdf file by your database connection string.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号