无法读取配置部分 'connectionStrings',因为它缺少部分声明

The configuration section 'connectionStrings' cannot be read because it is missing a section declaration

我正在尝试将我的网页 (c#) 移动到 ISS 7.5 服务器。

我读到我需要放入 WEBCONFIG 来实现与 sql server 2008 的连接。

我已经这样做了。

这是我的WEBCONFIG

<?xml version="1.0" encoding="UTF-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionstrings>
   <!-- <remove name="LocalSqlServer" /> -->
    <add name="conexionsql" connectionstring="Data Source=FCH-DESARROLLO;Initial Catalog=DesaInterno;Integrated Security=True;User ID=usuario_de_conexion;Password=a"
     providerName="System.Data.SqlClient"/>
  </connectionstrings> 


  <system.web>

    <!--<identity impersonate="true" /> -->

    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <!--  <add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> -->
        <add assembly="*" />
      </assemblies>
    </compilation>
   <!-- <httpRuntime targetFramework="4.5"/> -->
  <!--  <authentication mode="Windows" /> -->
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>


 <!-- <system.webServer> -->
   <!-- <defaultDocument>
      <files>
        <add value="index.aspx" />
      </files>
    </defaultDocument> -->

  <!--</system.webServer> -->
   <!-- <connectionStrings>
        <remove name="LocalSqlServer" />
        <add connectionString="Server=10.10.201.79;Database=DesaInterno;Integrated Security=true" name="LocalSqlServer" />
    </connectionStrings> -->
</configuration>

当我尝试 run 我在 IIS 中的应用出现错误。

Error HTTP 500.19 - Internal Server Error The configuration section 'connectionStrings' cannot be read because it is missing a section declaration

连接字符串部分具有以下定义并且区分大小写

<connectionStrings>
     <add name="conexionsql" connectionstring="Data Source=FCH-DESARROLLO;Initial Catalog=DesaInterno;Integrated Security=True;User ID=usuario_de_conexion;Password=a"
 providerName="System.Data.SqlClient"/>
</connectionStrings>

这是因为按键 区分大小写 而你的全是小写 connectionstrings,只需更改为正确的大小写 connectionStrings (注意大写 S).

完整的配置(删除了多余的项目)现在看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <add name="conexionsql" connectionstring="Data Source=FCH-DESARROLLO;Initial Catalog=DesaInterno;Integrated Security=True;User ID=usuario_de_conexion;Password=a"
     providerName="System.Data.SqlClient"/>
  </connectionStrings> 

  <system.web>
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="*" />
      </assemblies>
    </compilation>
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>
</configuration>
  <configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.0"/>
    </system.web>
    <connectionStrings>
      <add name="#" connectionString="#" providerName="System.Data.SqlClient"/>
    </connectionStrings>
  </configuration>

用上面的配置替换你的代码

此外,标签的大小写应与给定的完全一致

如果您仍然卡住,请告诉我,这可能是其他问题。