我怎样才能授予使用通配符需要身份验证的网站的一个HttpHandler匿名访问? [英] How can I grant anonymous access to an httpHandler that uses wildcards in a site that requires authentication?

查看:241
本文介绍了我怎样才能授予使用通配符需要身份验证的网站的一个HttpHandler匿名访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要验证,但有一些相关的服务,可以调用应用程序为匿名的应用程序。呼叫是经由HttpHandlers的,其中一些使用通配符制成。对于不使用通配符的HttpHandlers的,我可以在web.config中使用位置元素管理安全:

I have an application which requires authentication, but has some related services which can call into the application as anonymous. The calls are made via httpHandlers, some of which use wildcards. For the httpHandlers that do not use wildcards, I can manage the security by using the location element in web.config:

<httpHandlers>
  <add verb="*" path="ProcessFile.ashx" type="..." validate="false" />
  <add verb="*" path="DoSomethingElse.*.*.ashx" type="..." validate="false" />
</httpHandlers>

对于第一个处理程序,很容易(不再赘述结束标记):

For the first handler, it was easy (closing tags omitted for brevity):

<location path="ProcessFile.ashx">
  <system.web>
    <authorization>
      <allow users="?" />
    ...

第二个处理器将无法工作,因为位置不会采取通配符。我试图用一个目录,但它似乎并没有工作:

The second handler won't work because location will not take wildcards. I tried using a 'directory' but it doesn't seem to work:

<httpHandlers>
  ..
  <add verb="*" path="test/DoSomethingElse.*.*.ashx" type="..." validate="false" />
</httpHandlers>


<location path="test">
  <system.web>
    <authorization>
      <allow users="?" />
    ...

有没有办法得到这个工作?我是否有语法错误以某种方式?

Is there a way to get this to work? Do I have the syntax wrong in some way?

推荐答案

我会建议你隔离处理程序预计将匿名使用到一个公共文件夹,然后设置位置权限该文件夹是普遍可用。所以,如果你有一个处理一个文件夹 /处理程序和子文件夹 /公共然后你可以有以下内容:

I would recommend segregating your handlers that are expected to be anonymously available into a common folder and then set the location permissions for that folder to be universally available. So if you have a folder for handlers /Handlers and a subfolder /Public then you could have the following:

<location path="/Handlers/Public">
    <system.web>
        <authorization>
            <allow users="*"/>
        </authorization>
    </system.web>
</location>

然后,你可以把你的通配符处理程序在这里,无需通过个人名义来指定。

Then you can put your wildcard handlers in here without having to specify it by individual name.

这篇关于我怎样才能授予使用通配符需要身份验证的网站的一个HttpHandler匿名访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆