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

4

6

I am trying to move my webpage(c#) to ISS 7.5 server.

I have read that i need to put the in WEBCONFIG to achieve the conection with sql server 2008.

I already did that.

Here is my 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>

When i try tu run my app in IIS comes an error.

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

Yellowthroat answered 6/1, 2015 at 11:45 Comment(0)
U
2
  <configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.0"/>
    </system.web>
    <connectionStrings>
      <add name="#" connectionString="#" providerName="System.Data.SqlClient"/>
    </connectionStrings>
  </configuration>

replace your code with above configuration

as well the tag should be in proper case exact as given

let me know if you still stuck its might be some other issue.

Undertow answered 6/1, 2015 at 12:16 Comment(0)
T
1

I solved my issue by copying machine.config file from the backup server.

Toby answered 12/6, 2023 at 8:19 Comment(0)
G
0

The connection string section has the following definition and is case-sensitive:

<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>
Goniometer answered 6/1, 2015 at 11:55 Comment(0)
S
0

This is because the keys are case-sensitive and you have it all lower-case connectionstrings, simply change to the correct case connectionStrings (note upper-case S).

Complete config (with redundant items removed) now looks like this:

<?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>
Saucedo answered 6/1, 2015 at 11:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.