在web.config中的位置路径属性的普通防爆pression(带参数) [英] Regular Expression on web.config location path attribute (with parameters)

查看:141
本文介绍了在web.config中的位置路径属性的普通防爆pression(带参数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有做这样的事情的方法吗?

Is there any way of doing something like this?

<location path="/(view|edit)post.aspx\?id=[7-9][0-9]+">
    <system.web>
      <authorization>
        <allow roles="AdminPublishers"/>
        <deny users="*"/>
      </authorization>
    </system.web>
</location>

授权仅仅是一个例子。我希望能够做其他事情与地点。

Authorization is just an example. I would like to be able to do other things with those locations.

推荐答案

您可以使用一个HttpModule,并附加一个句柄到的AuthenticateRequest事件。内部处理程序,使用正则表达式来匹配传入的请求URL,如果匹配,检查谁是当前登录的用户的角色,你也可以将它设置为从Web.config读取配置,如果这就是你后。

You could use an HttpModule and attach a handler to the AuthenticateRequest event. Inside your handler, use your Regex to match against the incoming Request Url, and if it matches, check the roles of the user who is currently logged in. You could also set it up to read configuration from the Web.config, if that's what you're after.

这篇关于在web.config中的位置路径属性的普通防爆pression(带参数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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