Set your IHttpHandlers using RouteTable rather than web.config

If for whatever reason you use IHttpHandlers in your MVC project, it may be that you are still using web.config to set the path to the handlers. This can get tricky and easy to miss, especially if you move from cassini dev to IIS7 live.

There is however a better, neater way to declare paths to your handers. If you are using MVC, you can register the handlers in RouteTable, along with your other routes. All you need to do is implement IRouteHandler interface and register a route using your custom route handler.

Furthermore, you can add tokens on the route while you’re registering the handlers to the RouteCollection. These can be identified by the routehandler and passed down to the handler as arguments.

Lets assume you have a handler that looks after your file upload. The same handler is re-used for multiple different file upload processes and we need to be aware, which upload type it is. The handler should be registered at ~/handlers/uploadfile/{type}