views:

301

answers:

1

Is it possible for a .NET assembly in an ASP.NET web site's Bin folder to automatically respond to certain incoming HTTP requests, as if it had an httpHandlers entry in the web site's web.config file, but without actually having to add that entry?

For example an assembly may contain the following metadata to get some embedded static resource to be available in an ordinary HTTP request:

[assembly: System.Web.UI.WebResource("SomeManifestResource", "image/gif")]

I'm looking for similar functionality that instead of returning a static resource will actually invoke an HttpHandler that is defined the assembly. Again, without actually having to add the entry to the web.config file.

+2  A: 

No that is simply not possible.

Everything in ASP.NET that responds back with HTML output is HttpHandler somewhere in the inheritance hierarchy. So HttpHandlers are really one of the most critical part of ASP.NET runtime. Even your asp.net pages [aspx,ascx] do implement IhttpHandler to be able to serve HTML content.

You must configure them in your web.config to have them work for you.

this. __curious_geek
Is it possible to have a MasterOfAllHandlersHandler that would load all handlers with a specific interface/attribute? And you only add the Master to the web.config file, and the rest are just code files in App_Code?
Simon Svensson
I was actually looking forward to include something like this in my reply. Can you explain me your scenario or application context, in order to come up with a right applicable solution for this ? Thnx.
this. __curious_geek
Check out www.postsharp.org. This might help you to an extent.
this. __curious_geek