【问题标题】:Web.config: put an comment inside xml attributesWeb.config:在 xml 属性中添加注释
【发布时间】:2010-05-16 07:06:26
【问题描述】:

我想在web.config 文件中添加评论,如下所示:

<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
  />

有没有办法以这种方式放置 cmets,使用像 &lt;% %&gt; 这样的服务器端 cmets 之类的?

【问题讨论】:

  • 缺乏执行此操作的能力是我越来越多地认为 xml 不是复杂配置文件的正确格式的原因。我认为 yaml 可能是前进的方向——它具有 xml 所缺乏的一种优雅的简单性。

标签: asp.net web-config xml-comments


【解决方案1】:

web.config 文件是一个 XML 文件,因此您唯一的选择是使用 XML cmets:

<!--
   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"      
/>

【讨论】:

    【解决方案2】:

    您可以评论 web.config 的任何部分以了解如何执行此操作!

    无论如何

    <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-->
      />
    

    【讨论】:

    • 这在 XML 中无效。注释不能在属性区域。这就是为什么我问也许有一个 secret 服务器端评论类型。
    猜你喜欢
    • 1970-01-01
    • 2011-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-25
    • 2014-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多