我正在尝试将MVC5网站部署到IIS7服务器。本网站使用Asp.net会员资格。
当尝试连接到我的SQlServer时,网站正在尝试使用machine.config connectionstring" LocalSqlServer"。
但我没有指定使用此ConnectionString。如何更改此行为,因此它使用web.config中的给定connectionString而不是machine.cofnig。
public ApplicationDbContext()
: base("XXXXMembership", throwIfV1Schema: false)
{
}
Web.Config:
<connectionStrings>
<add name="XXXXMembership" connectionString="Data Source=xxxxxxxx;Initial Catalog=xxxxx;user id=xxxxx;password=xxxx;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>
答案 0 :(得分:1)
将其添加到<connectionStrings>
部分的顶部
<connectionStrings>
<clear />
<remove name="LocalSqlServer" />
<add name="XXXXMembership" connectionString="Data Source=xxxxxxxx;Initial Catalog=xxxxx;user id=xxxxx;password=xxxx;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>
答案 1 :(得分:1)
发布应用程序时,请确保更改要在向导中使用的数据库。
答案 2 :(得分:1)
@stevenackley添加解决方案并将其添加到我的LocalWebConfig后。它有效。
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="XXXMembership" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
<add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" connectionStringName="XXXMembership" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add name="MySQLProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
</providers>
</profile>
<roleManager>
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" connectionStringName="XXXMembership" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
</providers>