Last post Jun 11, 2009 08:03 AM by SimonRigby
Jun 09, 2009 09:45 AM|SimonRigby|LINK
Written a little handler to stop browsing to certain assets. I have a folder called 'assets' and I would like to route all requests for files within that directory or sub directories through the handler. I think I'm looking for the correct syntax for the
web.config HttpHandlers section.
Placing files within the root of assets and using:
<add verb="GET" path="assets/*.*" type="AssetShieldSite.AssetShield"/>
works fine but doesn't work when accessing a subdirectory of assets. Have tried
<add verb="GET" path="assets/*" type="AssetShieldSite.AssetShield"/>
which didn't work.
Sorry if this has been asked before but a good search didn't get me an answer.
(Note: adding all subdirectories involved to the web.config file is a non-starter for me as the application allows the admin to configure access to certain directories - and those directories will change - and the permissions scheme is not as simple as access
or not. So I'm looking for a way of passing any request from assets -> downwards, to the handler where it can then inspect the request and retreive permissions from the database to decide whether to allow access or not - based on certain criteria. The handler
itsself does all of this and works fine, it purely the mechanism of getting it to recognise any request within assets - no matter how deeply nested - that I need).
Jun 10, 2009 04:10 PM|eric2820|LINK
I'm telling you from personal experince that you'll be better able to accomplish what you want with an HttpModule better than you'll be able to with an HttpHandler.
An HttpModule can inspect every url a visitor to your site requests. For some it can perform work, and for others it can return without doing much at all.
An HttpHandler is designed to handle a specific type of request, usually a custom file extension.
From your description and your note at the end, it's obvious to anybody with the proper hindsight that you need to use an HttpModule if you want more success.
Jun 11, 2009 08:03 AM|SimonRigby|LINK
Thanks very much for that. Spent the morning reading up and I agree completely this sounds like a plan.