2

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 ?

John Conde
  • 217,595
  • 99
  • 455
  • 496
Waqar Janjua
  • 6,113
  • 2
  • 26
  • 36

2 Answers2

3

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.

Kirill
  • 3,028
  • 1
  • 17
  • 18
  • I want to use Createuserwizard as I use a textbox control. I does not want to use MembershipProvider. Is it possible to use it without membership ? as we use standard asp.net controls like label,textbox etc – Waqar Janjua Jul 23 '11 at 16:57
  • 1
    Just use a regular [asp:Wizard](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.wizard.aspx) control instead. Put a couple of textboxes and a couple of [validators](http://msdn.microsoft.com/en-us/library/aa479013.aspx) on it and store user data on FinishButtonClick by yourself. Refer to this [tutorial](http://www.codeproject.com/KB/aspnet/Wizard_Control.aspx) for more detailed info. – Kirill Jul 23 '11 at 17:28
0

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

enter image description here

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.

Samir Adel
  • 2,691
  • 2
  • 15
  • 16
  • Thanks for replying. I does not want to use membership tables. I only want to use create user wizard control. – Waqar Janjua Jul 23 '11 at 15:21
  • To use the create user wizard control need to save the information of the created user in the database and that's why the asp.net added the .mdf file to your app_data to save it's required information so to be able use the create user wizard you will need the database tables to hold this information. – Samir Adel Jul 23 '11 at 15:30
  • yeah, but I does not want to store user Info in aspnetdb tables. I create a new database test and a table User. I want to store user info in the User table. I does not want to add aspnetdb tables to my database test. Why createuserwizard is dependent upon aspnetdb or asp.net membership ? – Waqar Janjua Jul 23 '11 at 15:34
  • It's dependent on the ASP.Net Membership Provider, but to do what you want you will need to write your own membership provider to map on to your own table. If you do want to use the ASP.Net Membership tables in your own DB you can use a tool called aspnet_regsql.exe (available in your C:\Windows\Microsoft.Net\Framework\V2 directory) to add the standard membership tables to your own database. – ITHedgeHog Jul 23 '11 at 19:04