设置默认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配置(卡西尼开发服务器)将无法连接到远程服务器。
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:\\ WINDOWS \\ Microsoft.NET \\框架\\ V2.0.50727 \\ CONFIG)总是指向本地主机上运行的SQL Server中。
After much searching I found that the default Membership Provider specified in machine.config (c:\windows\Microsoft.NET\Framework\v2.0.50727\CONFIG) was always pointing to a SQL Server running on the localhost.
而不是修改machine.config中有一种方法来设置它在web.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)&LT;&的System.Web GT;
重新定义默认提供:
<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>
的&LT;清除NAME =AspNetSqlMembershipProvider/&GT;
是关键!所有其他的键/值直接从machine.config中取
The <remove name="AspNetSqlMembershipProvider"/>
is key! All the other key/values were taken directly from machine.config
这篇关于设置默认AspNetSqlProvider指向远程数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!