I.T. Discussion Community!
-Collapse +Expand
Search C# Group:

-Collapse +Expand C# To/From
-Collapse +Expand C# Study Test
-Collapse +Expand C# Store

Prestwood eMagazine

March Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingC#   Print This     
  From the September 2008 Issue of Prestwood eMag
Applying the Built-in ASP.NET User-Login Functionality to Your Database
Posted 11 years ago on 7/22/2008 and updated 9/1/2008
Take Away: Using aspnet_regsql.exe to set up a database to support the functionality of ASP.NET 2.0's built-in membership.


In order to use your own SQL Server database to store login information using the built-in ASP.NET 2.0 Membership functionality, you must run the aspnet_regsql.exe tool. If this is not done the site defaults to using the ASPNETDB.MDF database located in the App_Data folder and will not be connected to any existing databases.

The aspnet_regsql.exe tool is located under [drive]:\...\Microsoft.NET\Framework\[versionnumber]

(Default location is C:\Windows\Microsoft.NET\Framework\[versionnumber])

This tool can be run with command-line arguments to specify settings.
These include:
    -C <connectionstring> :: specifies the connection string to the database
    -S <server> :: specifies the server the database is located on
    -A all/m/r/p/c/w :: adds support for asp.net services
            m: membership
            r: roles
            p: profiles
            c: web parts
            w: web events
    -R all/m/r/p/c/w :: removes support for above services
    -d <database> :: specifies the name of the database

This tool can also be run without command-line arguments in order to pop up a wizard which steps through the process of setting up the database.

Once the database is set up you must change the Membership provider. This can be done by adding this code to your web.config:

  <add name="YourConnectionString" connectionString="..." />

  <roleManager enabled="true"
    <add name="MyRoleProvider" type="System.Web.Security.SqlRoleProvider"
          connectionStringName="YourConnectionString" />

  <membership defaultProvider="MyMembershipProvider">
    <add name="MyMembershipProvider"
      connectionStringName="YourConnectionString" />

You can then go into the ASP.NET Configuration and select the new provider by selecting the "Select a different provider for each feature (advanced)" link under the Providers tab.


Share a thought or comment...
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1252A1
Enter key:
KB Post Contributed By Stephen Berry:
Visit Profile

 KB Article #101291 Counter
Since 7/22/2008
   Contact Us!
PrestwoodBoards.com was developed and is maintainted by me. Do you have a question or suggestion? Do you see a problem? Contact me now. My goal is to build an ad-free and spam-free source of I.T. information with many contributers (ok to promote your website/company in your bio). Yes, my company Prestwood IT Solutions is mentioned in my bio which shows with every post, but you can contribute and promote your pet project too!

1,999 People Online Now!!  
Sign In to see who's online now!  Not a member? Join now. It's free!
Show more stats...

©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech