设置默认的 AspNetSqlProvider 指向远程数据库 [英] Setting up the default AspNetSqlProvider to point to remote database
问题描述
当开始一个需要使用成员资格提供程序的新项目时,我发现我无法连接到包含成员资格数据库的远程数据库.
When starting a new project that required the use of membership providers I found that I could not connect to a remote database that contained the membership database.
我运行了 aspnet_regsql 并且能够在远程服务器上创建成员资格数据库,但是当我转到 ASPNET 配置(cassini 开发服务器)时,它无法连接到远程服务器.
I ran aspnet_regsql and was able to create the membership database on the remote server but when I go to ASPNET Configuration (cassini development server) it will not connect to the remote server.
推荐答案
经过多次搜索,我发现 machine.config (c:windowsMicrosoft.NETFrameworkv2.0.50727CONFIG) 中指定的默认 Membership Provider总是指向在本地主机上运行的 SQL Server.
After much searching I found that the default Membership Provider specified in machine.config (c:windowsMicrosoft.NETFrameworkv2.0.50727CONFIG) was always pointing to a SQL Server running on the localhost.
有一种方法可以在项目 web.config 中设置它,而不是修改 machine.config:
Instead of modifying machine.config there is a way to set it up in the projects web.config:
1) 设置到远程数据库的连接字符串
1) Setup the connection string to the remote database
<connectionStrings>
<add name="aspnet_membership" connectionString="<your_connection_string>"/>
</connectionStrings>
2) 在
中重新定义默认提供者:
2) In <system.web>
redefine the default provider:
<membership>
<providers>
<remove name="AspNetSqlMembershipProvider"/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="aspnet_membership"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""/>
</providers>
</membership>
<remove name="AspNetSqlMembershipProvider"/>
是关键!所有其他键/值直接取自 machine.config
The <remove name="AspNetSqlMembershipProvider"/>
is key! All the other key/values were taken directly from machine.config
这篇关于设置默认的 AspNetSqlProvider 指向远程数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!