3

设想

我正在使用自定义IPrincipalIIdentity进行 asp.net 授权。我在Principal活动期间使用.IdentityPostAuthenticateRequestIHttpModule

web.config 大致如下所示:

<system.web>
  <authorization>
    <allow verbs="GET,POST" roles="domain\group"/>
    <deny verbs="*" users="*"/>
  </authorization>
</system.web>
<location path="~/admin/user_search.aspx">
  <system.web>
    <authorization>
      <allow verbs="GET,POST" roles="admin"/>
      <deny verbs="*" users="*"/>
    </authorization>
  </system.web>
</location>

问题

发出请求时,该IPrincipal.IsInRole方法会被调用一次以进行检查domain\group,但不会再次被调用以检查admin角色。这是什么原因造成的?我的location语法不正确还是有更深层次的问题?

笔记

我最初认为 admin 目录中的 web.config 覆盖了根目录中的 web.config,但我尝试完全删除它并将其用于location元素。到目前为止,两者都没有工作。

4

1 回答 1

3

Don't use the tilde (~) at the start of paths for <location> elements, as they are not interpreted there. In your example, path="admin/user_search.aspx" should be correct.

于 2009-02-24T23:44:40.910 回答