Possible Duplicate:
Any way to add HttpHandler programatically in .NET?
Is there a way I can dynamically register an IHttpHandler in C# code, instead of having to manually add it to the system.web/httpHandlers section in the web.config.
This may sound crazy, but I have good reason for doing this. I’m building a WidgetLibrary that a website owner can use just by dropping a .dll file into their bin directory, and want to support this with minimal configuration to the web.config.
I don’t believe it’s possible to modify the registered HttpHandlers once the AppDomain is running because the available handlers is read directly from the
web.configfile then cached in a private data structure.If you knew upfront which extensions you wanted to allow, you could do is map these extensions to a single
HttpHandlerFactoryand then return a handler of your choice (by using dynamic assembly loading and reflection). For example:Modifying the
web.configat runtime would cause the AppDomain to restart.