So you have a class that implements IHttpHandler called: MyHandler and it's in the namespace Example, you need to make the following entries in the site's Web.Config in the httpHandlers section:
<httpHandlers>
<add verb="*" path="*" type="Example.MyHandler"/>
</httpHandlers>
Since this redirects all URLs for your web site/application to your handler you have to consider how to serve static content (imgs, scripts, style sheets etc). One way is to store such static content in a consistent URL like http://example.com/static/..., you can then set your handlers as such:
<httpHandlers>
<add verb="*" path="*" type="Example.MyHandler"/>
<add verb="GET,HEAD" path="static/*" type="System.Web.StaticFileHandler" />
</httpHandlers>
For your local dev webserver (embedded in Visual Studio) this is all that's needed. For IIS, you also need to tell IIS how to deal with these URLS (since the server first analyses a request to decide where to send it - including whether to send it to ASP.NET or some other extension).
- Open: IIS Manager ->
- Section: Websites ->
- Right click on your website ->
- Option: Properties ->
- Tab: Home Directoy ->
- Button: [Configuration...] ->
- Tab: Mappings ->
- Section: "Wildcard application maps (order of implementation):" ->
- Button: [Insert...] ->
- Executable: "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" (or whichever version of the .NET runtime your handler uses) ->
- Uncheck "Verify that file exists" ->
- Button: [OK]
Now both IIS and ASP.NET know how to deal with your URLS.
The above approach means when requesting static files, ASP.NET is actually serving the files, not IIS - which leads to a few disadvantages (discussed here). You can override this behaviour (disable wildcard mapping from the static directory) by switching the directory to an application (in IIS Manager), removing the wildcard mapping statement (added above) and switching it back from an application. Voilà - static files are handled by IIS without pestering your ASP.NET.