分析器错误消息:无法识别的配置部分httpCookies

时间:2012-02-14 22:03:00

标签: asp.net asp.net-mvc-3 web-config

我已将以下内容添加到我的asp.net mvc3中的web.config文件中,以阻止脚本访问Cookie: <httpCookies domain="String" httpOnlyCookies="true" requireSSL="false" />,如下:

<appSettings>
    <add key="webpages:Enabled" value="false" />
  </appSettings>
  **<httpCookies domain="String" httpOnlyCookies="true" requireSSL="false" />**
  <system.web>

    <httpHandlers>
      <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
    </httpHandlers>

但是当我运行应用程序时,它引发了以下错误: - 分析器错误消息:无法识别的配置部分httpCookies。

1 个答案:

答案 0 :(得分:2)

<httpCookies>元素是<system.web>元素的子节点,因此您必须将其放入:

<appSettings>
    <add key="webpages:Enabled" value="false" />
</appSettings>

<system.web>
    <httpCookies domain="String" httpOnlyCookies="true" requireSSL="false" />

    <httpHandlers>
        <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
    </httpHandlers>

...
</system.web>