I’ve been researching this a bit but haven’t come across an answer — is there any way to programatically add an HttpHandler to an ASP.NET website without adding to the web.config?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
By adding an HttpHandler I assume you mean the configuration files
There is a way to control it automatically, by adding the
IHttpHandlerin directly during the request. So on the PostMapRequestHandler in the Application Lifecycle, you would do the following, in your own customIHttpModule:And that would automatically set the handler for that request. Obviously you probably want to wrap this in some logic to check for things such as verb, requesting url, etc. But this is how it would be done. Also this is how many popular URL Rewriters work such as:
http://urlrewriter.codeplex.com
Unfortunately though, using the pre built configuration handler that the web.config does, is hidden away and doesn’t seem to be accessible. It is based off an interface called
IHttpHandlerFactory.Update The
IHttpHandlerFactorycan be used just like any other IHttpHandler, only it is used as a launching point instead of a processing point. See this article.https://web.archive.org/web/20140227135526/http://www.uberasp.net/getarticle.aspx?id=49