Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# mvc5iis;在web.config之前使用machine.config_C#_Asp.net Mvc_Iis_Web Config_Asp.net Membership - Fatal编程技术网

C# mvc5iis;在web.config之前使用machine.config

C# mvc5iis;在web.config之前使用machine.config,c#,asp.net-mvc,iis,web-config,asp.net-membership,C#,Asp.net Mvc,Iis,Web Config,Asp.net Membership,我正在尝试将MVC5网站部署到IIS7服务器。该网站使用Asp.net成员身份 当尝试连接到我的SQlServer时,网站正在尝试使用machine.config connectionstring“LocalSqlServer” 但是我没有指定使用这个ConnectionString。如何更改此行为,使其使用web.config中的给定connectionString而不是machine.cofnig public ApplicationDbContext() : b

我正在尝试将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>

将其添加到
部分的顶部

<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>

发布应用程序时,请确保更改向导中要使用的数据库。

@stevenackley在添加您的解决方案并将其添加到我的本地网络配置后。它起作用了

<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>


尝试了这个。没有任何变化。这是唯一的DBContext吗?在添加解决方案并将其添加到我的LocalWebConfig之后。它起作用了,这让我有过一次。花了一整天的时间试图弄明白为什么我的prod代码碰到了我的dev数据库lol