Why CreateUserWizard Control automatically adds the ASPNETDB.MDF database?

丶灬走出姿态 提交于 2019-12-10 10:37:59

问题


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: Can we use CreateUserWizard with custom database with out using ASPNETDB or asp.net membership ?


回答1:


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.




回答2:


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

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.



来源:https://stackoverflow.com/questions/6801132/why-createuserwizard-control-automatically-adds-the-aspnetdb-mdf-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!