I have written a httphandler to intercept all pdf files request via URL from a specific folder and redirect the user to Login page. If the user is authenticated the file can be downloaded. My web.config has the following entry for the interception
<httpHandlers>
<add verb="*" path="/calderdale/*.pdf"
type="NES.HiLo.Security.CalderDaleAuthenticationHandler, NES.HiLo.Security" />
</httpHandlers>
In IIS (6.0) Application extension settings I have added a setting with executable C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
and extension Pdf.
This works but every pdf file request is getting intercepted rather the the files present in calderdale directory.
I have tried solutions given on this link Mapping specific folder to HttpHandler in web.config and removed the application extension setting but then handler does get call at all.
Any ideas?
I think the trick here is to only register the HttpHandler for that specific directory. This can be done by moving the system.web/httpHandlers content into a location node in your web.config. For instance:
<location path="calderdale">
( system.web/httpHandlers content )
</location>
Add this to your main web config:
<location path="static">
<system.web>
<httpHandlers>
<add verb="GET,HEAD" path="*.*"
type="NES.HiLo.Security.CalderDaleAuthenticationHandler, NES.HiLo.Security" />
</httpHandlers>
</system.web>
</location>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With