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

Advanced
-Collapse +Expand C# To/From
To/FromCODEGuides
-Collapse +Expand C# Study Test
PRESTWOODCERTIFIED
-Collapse +Expand C# Store
PRESTWOODSTORE

Prestwood eMagazine

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

   ► KBProgrammingC#   Print This     
  From the September 2008 Issue of Prestwood eMag
 
C#:
Applying the Built-in ASP.NET User-Login Functionality to Your Database
 
Posted 10 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.

KB101291



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:

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

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

  <membership defaultProvider="MyMembershipProvider">
   <providers>
    <add name="MyMembershipProvider"
      type="System.Web.Security.SqlMembershipProvider"
      connectionStringName="YourConnectionString" />
   </providers>
  </membership>

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.


Comments

0 Comments.
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 = P1242A1
Enter key:
KB Post Contributed By Stephen Berry:
Visit Profile

 KB Article #101291 Counter
5558
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!

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


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