Add HttpHandlers Programmatically

  • Thread starter Thread starter TJoker .NET
  • Start date Start date
T

TJoker .NET

I have this web control that need to process some special
urls requested by the browser. So I created a class
implementing IHttpHandler to deal with it.
The problem here is that to properly use the control, the
developer has to include something like the following in
his web.config:

<httpHandlers>
<add verb="*" path="MySpecialResource.ashx"
type="MyRequestHandler, MyAssembly"/>
</httpHandlers>

My goal is to simplify as much as I can the usage of the
control, trying to make it as drag n'drop as possible.
So the question would be: Is there a way to
programmatically add HttpHandlers to an ASP.NET
application ?
Or, should I be using something else ?

Thanks

TJ
 
TJoker said:
I have this web control that need to process some special
urls requested by the browser. So I created a class
implementing IHttpHandler to deal with it.
The problem here is that to properly use the control, the
developer has to include something like the following in
his web.config:

<httpHandlers>
<add verb="*" path="MySpecialResource.ashx"
type="MyRequestHandler, MyAssembly"/>
</httpHandlers>

My goal is to simplify as much as I can the usage of the
control, trying to make it as drag n'drop as possible.
So the question would be: Is there a way to
programmatically add HttpHandlers to an ASP.NET
application ?
Or, should I be using something else ?

I'm not very experienced in this area, but you probably should look at
VS.NET's design-time support for controls (and possible the IDE's object
model for extensibility).

Look at the documentation for "Enhancing Design-Time Support". This
documents how controls can get notification of events when they are
selected, dropped, etc.

You might also need to look at the "Automation and Extensibility
Reference" which provides an object model for VS.NET's solutions and
projects (among other things).

Once again, I'm not experienced in this, but I think a possible approach
is to use the functionality in the System.ComponentModel.Design
namespace to get notification of when your control is added, then use
the VS.NET automation model to get to the project's web.config file and
add your stuff.
 
Back
Top