Web.Config中的模拟标记

时间:2011-08-02 21:30:42

标签: asp.net web-config impersonation

我在Asp.net 4.0网站的web.config中使用了impersonate标记。

以下是我的Web.Config代码:

<system.web>
    <authentication mode="Windows">
        <identity impersonate="true"                 
            userName="Administrator" 
            password="LALLA$26526"/>
     </authentication>
</system.web>

当我在Visual Studio中运行应用程序时,出现此错误:

Parser Error Message: Unrecognized element 'identity'.

来源错误:

Line 50:    <system.web>
Line 51:        <authentication mode="Windows">
Line 52:            <identity impersonate="true"             
Line 53:                 userName="Administrator"
Line 54:                 password="LALLA$26526"/>

我哪里错了?

3 个答案:

答案 0 :(得分:71)

identity部分位于system.web部分下方,不在authentication下:

<system.web>
  <authentication mode="Windows"/>
  <identity impersonate="true" userName="foo" password="bar"/>
</system.web>

答案 1 :(得分:9)

identity元素放在authentication元素

之前

答案 2 :(得分:8)

您将identity节点作为authentication节点的子节点。那就是问题所在。如上例所示,authenticationidentity节点必须是system.web节点的子节点