How do I pre-empt IIS StaticFileHandler with my own HttpHandler

Posted by Hmobius on Stack Overflow See other posts from Stack Overflow or by Hmobius
Published on 2009-04-30T11:51:14Z Indexed on 2010/04/13 23:03 UTC
Read the original article Hit count: 340

Filed under:
|
|

Hi there,

I'm building a website referencing an assembly that contains several js scripts as embedded resources, some controls which use those scripts and a 'HttpResourcesHandler' that knows how to retrieve those embedded scripts when asked for them.

In web.config I have an entry in the section that reads

<add verb="*" 
     path="/embedded/controlscripts/*" 
     validate="false" 
     type="CWeb.Controls.Web.HttpResourcesHandler, CWeb.Controls.EditBox" />

This control adn the website work absolutely fine when debugging with the Visual Studio web development server, but if I then switch the website to run under IIS (v7 - I'm running Vista and there appears to be no problem with debugging the site using IIS 5 or 6), the control can no longer access the scripts. I get a HTTP 404.0 error screen indicating the StaticFileHandler cannot find the file. I know that - it's embedded.

So the StaticFileHandler appears to be grabbing the request for the script before my own and returning a 404. How do I tell IIS to use my own resource handler for the embedded/controlscripts directory rather than the staticfilehandler? I'm running the website in classic mode by the way.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about iis7