数据库文件和ASP.NET Login控件 [英] Database files and ASP.NET Login controls
问题描述
我试图在ASP.NET登录控件的教程和一切正常。但是,我不知道怎么有登录控制使用自己的数据库(SQL Server 2005),而不是使用它的MDF文件。我不知道在哪里这个文件是从,因为它根本不显示在我的解决方案创建的。我能找到的登录控制的运作的任何文献将大大AP preciated。
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.
推荐答案
当您使用ASP.NET的会员功能,你需要指定供应商。在Machine.config文件(住在C:\\ WINDOWS \\ Microsoft.NET \\框架\\ [版本] \\ CONFIG)默认提供者指定使用在App_Data文件夹本地.mdf文件。既然你不希望出现这种情况,你可以重写它在你的应用程序的web.config文件中,像这样:
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.
现在,你需要真正在服务器上创建数据库/表。要做到这一点,使用C:\\ WINDOWS \\ Microsoft.NET \\框架\\ [版本] \\ aspnet_regsql.exe的。为您提供的连接字符串应指向此实用程序会为你创建数据库。
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.
这篇关于数据库文件和ASP.NET Login控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!