【问题标题】:Impersonate tag in Web.Config在 Web.Config 中模拟标签
【发布时间】:2011-10-18 15:13:18
【问题描述】:

我在 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"/>

我哪里错了?

【问题讨论】:

    标签: asp.net web-config impersonation


    【解决方案1】:

    identity 元素放在authentication 元素之前

    【讨论】:

    • 可悲的是,这实际上是问题的正确答案。
    • @Aelphaeis 真的吗?职位很重要?
    • 如果 都是 的子级,那么顺序有什么关系呢?
    【解决方案2】:

    identity 部分位于 system.web 部分之下,而不是 authentication 之下:

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

    【讨论】:

    • 我高度怀疑野外存在一些糟糕的文档导致每个人都犯同样的错误;下一个遇到这个的人,你看到的不好的参考是什么?让我们从源头上修复它!
    • 你的意思是像 msdn.microsoft.com/en-us/library/72wdk8cc(v=vs.85).aspx 这样的糟糕文档,它说你可以将标识元素放在配置层次结构中的任何位置
    • 完美。给他们留下反馈。也许他们会让他们的文档更清晰。他们所说的“配置层次结构”是指它可以出现在哪种类型的配置文件中,而不是在配置文件中的位置。
    • 我知道你的意思。在页面底部,他们指定了 System.Web.Identity 部分,但对于第一次访问此内容的人来说,它仍然令人困惑。另外,现在 asp.net 抱怨集成管道中不支持此元素。
    【解决方案3】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-07
      • 2017-01-15
      • 1970-01-01
      • 2012-06-09
      • 2014-04-25
      • 2020-11-02
      • 1970-01-01
      • 2015-11-26
      相关资源
      最近更新 更多