20

I want to put an comment in web.config file, something like this:

<httpRuntime 
  requestValidationMode="2.0"      // require for [ValidateInput(false)] in .net-4.0
  requestPathInvalidCharacters=""  // include & character in the url
  enableVersionHeader="false"      // disable X-AspNet-Version header
  />

Is there any way to put comments in this way, using server-side comments like <% %> or something?

stacker
  • 14,641
  • 17
  • 46
  • 74
  • 2
    The lack of ability to do this is why I'm increasingly thinking that xml is not the correct format for complex configuration files. I'm thinking yaml is probably the way forward -- it has a kind of elegant simplicity that xml lacks. – Jules Mar 02 '13 at 09:27

2 Answers2

37

The web.config file is an XML file, so your only option is to use XML comments:

<!--
   requestValidationMode="2.0" - require for [ValidateInput(false)] in .net-4.0
   requestPathInvalidCharacters=""  - include & character in the url
   enableVersionHeader="false" - disable X-AspNet-Version header
-->
<httpRuntime 
  requestValidationMode="2.0"      
  requestPathInvalidCharacters=""  
  enableVersionHeader="false"      
/>
Oded
  • 489,969
  • 99
  • 883
  • 1,009
-15

you could comment any section of web.config to see how to do that !

anyways

<httpRuntime 
  requestValidationMode="2.0"      <!-- require for [ValidateInput(false)] in .net-4.0-->
  requestPathInvalidCharacters=""  <!--include & character in the url-->
  enableVersionHeader="false"      <!-- disable X-AspNet-Version header-->
  />
eugeneK
  • 10,750
  • 19
  • 66
  • 101
  • 16
    This is not valid in XML. The comment cannot be in the attributes area. that's why i'm asking maybe there is an *secret* server side comment type. – stacker May 16 '10 at 07:11