Choosing an HttpHandler from a Custom HttpModule

I have an HttpModule and I would like to select an HttpHandler for the current request, is this possible? In addition, web.config not an option, since the condition is not based on a path or extension. My error handling skills did not fail me, no matter what keywords I use, all the results are: "IHttpHandler vs IHttpModule".

+6
source share
3 answers

After spending a couple more hours, I finally found a solution:

HttpContext.RemapHandler

This allows me to conditionally reassign the request to another handler in my Url rewrite module.

+4
source

It seems to me that you are looking for an IHttpHandlerFactory . This can be registered in your web.config (I'm not sure if it is possible to register it using IHttpModule . See Walkthrough: Creating and Registering HTTP Server Loaders

Recently I came across an interesting post in which IHttpModule dynamically registered . I know that this is the opposite of what you are looking for, but it may seem interesting to you.

+1
source

You can create an HttpModule that will be launched for each request from the client (browser).

See here how he used cookies to send timezoneOFfset using an HttpModule.

http://weblogs.asp.net/cprieto/archive/2010/01/03/handling-timezone-information-in-asp-net.aspx

Download the code and see how it works.

Definitely you need some configuration changes.

0
source

All Articles