views:

647

answers:

2

I have been learning ASP.NET by experimenting, watching videos on ASP.NET, and reading forums. I haven't found a quick solution to this though.

Whenever I add the "login" or "createuserwizard" from the toolbox it always adds the new users to a database known as "ASPNETDB.MDF" even if I specify the remote database using a new SqlDataSource.

Is there an easy way to save the login information? Any tutorials that helped you?

+1  A: 

This sounds like you need to Implement a Custom Membership user

John Nolan
+1  A: 

By default, ASP.NET will use a local file based database to store the login information.

If you want to use a different database, you need to do a couple of things:

  1. Set up the Remote Database using aspnet_regsql.exe (usually found in C:\Windows\Microsoft.NET\Framework\v2.0.50727) - running this will start it in GUI mode, allowing you select a server and database to add the tables and stored procs to.
  2. Configure your web site to use this database. There are a few of places you need to do this:

In the ConnectionStrings section of the web.config add your new ConnectionString:

<add 
  name="zhpCoreContentConnectionString"
  connectionString="Data Source=Hobbiton\SqlExpress;Initial Catalog=zhpCoreContent;Integrated Security=True" 
  providerName="System.Data.SqlClient"/>

In the MembershipProvider section of the web.config, ensure the ConnectionString attribute is set to the same name as your connection string (other settings elided for berevity):

<membership>
  <providers>
    <add 
      connectionStringName="zhpCoreContentConnectionString"
      applicationName="/doodle"
      name="AspNetSqlMembershipProvider"
      type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </providers>
</membership>

If you are using Roles or Profiles you'll want to ensure that they are also using your connectionstring to store everything together, and ensure that the applicationName attribute is common between them.

Zhaph - Ben Duguid
Thanks for your help.I get the error:The entry 'AspNetSqlMembershipProvider' has already been added.
Miamian
Miamian
Glad to hear it :)
Zhaph - Ben Duguid