ASP.Net Does NOT accept <appsettings> tag

2

I am new to ASP.NET. I added following code to solve Validation Controls problem:

<appsettings>  
       <add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms">  
</add></appsettings>

But creating new bugs with adding this. Getting Error "HTTP Error 500.19" with this information:


The requested page cannot be accessed because the related configuration data for the page is invalid. The configuration section 'appsettings' cannot be read because it is missing a section declaration. Error Code: 0x80070032


My web.config content is simply this:

<?xml version="1.0"?>

<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->

<configuration>
   <system.web>
     <compilation debug="true" targetFramework="4.5" />
   <httpRuntime targetFramework="4.5" />

  </system.web>

   <appsettings>  
       <add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms">  
   </add></appsettings>  

</configuration>

I searched the web and didn't find a specific solution for this issue. And as I saw in related articles such errors may have many reasons. I don't know which one causing mine.

asp.net
asked on Stack Overflow Oct 3, 2013 by user2808671

2 Answers

4

XML is case sensitive. You are looking for <appSettings>, not <appsettings>:

<appSettings>  
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" />
</appSettings>

You can make the add element self-closing, but that is just a little nice syntactic sugar that isn't required.

More documentation about the appSettings element can be found on MSDN.

answered on Stack Overflow Oct 3, 2013 by vcsjones
3

Your add tag should be self-terminating, but as vcsjones points out, your issue is likely case sensitivity of <appSettings> (not <appsettings>)

   <appSettings>  
       <add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms"/>  
   </appSettings>  
answered on Stack Overflow Oct 3, 2013 by Nick Orlando • edited Oct 3, 2013 by Nick Orlando

User contributions licensed under CC BY-SA 3.0