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.
问题:
回答1:
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.
回答2:
A few excellent references for asp.net login controls:
Sitepoint
MSDN
And asp.net