Regular expression for web.config location path attribute (with parameters)

Is there a way to do 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 in these places.

+3
source share
1 answer

You can use the HttpModule and attach a handler to the AuthenticateRequest event. Inside the handler, use Regex to match the incoming request URL, and if it matches, check the roles of the user who is currently logged in. You can also configure it to read the configuration from Web.config, if you are after.

0
source

All Articles