Home > Enterprise >  HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related
HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related

Time:12-21

I have been trying to connect my ASP.NET Web Application (.NET framework) to my local SQL database but I've been getting the same error where it says that the "The configuration section 'connectionStrings' cannot be read because it is missing a section declaration" as seen in the picture below.

enter image description here This my web.config code.

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
      <connectionStrings>
          <add name = "Milestone3"
             connectionstring = "Data Source = (localdb)\MSSQLLocalDB;Initial Catalog=Milestone_2;Integrated Security=True"/>
      </connectionStrings>
    <compilation debug="true" targetFramework="4.7.2" />
    <httpRuntime targetFramework="4.7.2" />
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer " />
    </compilers>
  </system.codedom>
</configuration>  

I saw on other stack overflow questions that people deleted the .vs folder ad rebuilding the project but it still doesn't work. I also tried this but nothing happened

  1. Open control panel
  2. Click on “program” link (not uninstall programs)
  3. Click “turn windows features on/off” link
  4. Locate “Internet Information services IIS” in the pop up window and expand its node
  5. Expand the “World Wide Web Service” node
  6. Expand “Application Development Features” node
  7. Check the check box of “ASP.NET”
  8. Then click ok button

CodePudding user response:

The <connectionStrings> node should be a child of <configuration>, not a child of <system.web>. Change it to this:

<?xml version="1.0" encoding="utf-8"?>

<configuration>
  <connectionStrings>
    <add name = "Milestone3" connectionstring = "Data Source = (localdb)\MSSQLLocalDB;Initial Catalog=Milestone_2;Integrated Security=True"/>
  </connectionStrings>
  <system.web>         
    <compilation debug="true" targetFramework="4.7.2" />
    <httpRuntime targetFramework="4.7.2" />
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer " />
    </compilers>
  </system.codedom>
</configuration>  
  • Related