Database files and ASP.NET Login controls

I was trying the ASP.NET login control tutorial and everything works well. However, I do not know how to have the Log-in control use my own database (SQL Server 2005) instead of using it's mdf file. I also have no idea where this file was created from since it doesn't show up at all on my solution. Any literature that I can find on the workings of the Login control would be greatly appreciated.

Answers


When you use ASP.NET's Membership features, you need to specify a provider. In the machine.config file (which lives in C:\WINDOWS\Microsoft.NET\Framework\[version]\CONFIG) a default provider is specified that uses a local .mdf file in the app_data folder. Since you don't want that, you can override it in your app's web.config file like so:

<system.web>
  <membership defaultProvider="myMembershipProvider">
    <providers>
      <clear /> <!-- remove the default provider since we're not using it anymore -->
      <add type="System.Web.Security.SqlMembershipProvider"
           name="myMembershipProvider"
           connectionStringName="myConnectionString"
           applicationName="MyApplicationName" />
    </providers>
  </membership>
</system.web>

If you're using other features like roles, personalization, or profiles, you'll need to define providers for them as well in a similar way.

Now you need to actually create the database/tables on your server. To do this, use C:\WINDOWS\Microsoft.NET\Framework\[version]\aspnet_regsql.exe. The connection string for your provider should point to the database that this utility will create for you.


A few excellent references for asp.net login controls:

Sitepoint

MSDN

And asp.net


Need Your Help

PowerShell: How to cast as a User Object?

powershell casting active-directory

I've got the following code which connects to every computer on the domain and checks the members of the local administrators group:

Error deploying Grails 2.0.4 to Glassfish 3.1.2 Server

grails spring-security glassfish

I am using Spring Security Core 1.2.7.3 plugin and am getting this error when trying to deploy: