Programmatically adding an HttpHandlerAction

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
N

Nathan Sokalski

I am trying to programmatically add an HttpHandlerAction, but I am recieving
a read-only error. The code I am using is basically as follows:

Dim currhandlers As System.Web.Configuration.HttpHandlerActionCollection =
CType(System.Configuration.ConfigurationManager.GetSection("system.web/httpHandlers"),
System.Web.Configuration.HttpHandlersSection).Handlers
currhandlers.Add(New System.Web.Configuration.HttpHandlerAction(mypath,
"mytype", "*", False))

What do I need to do to add an HttpHandlerAction? Any help would be
appreciated. Thanks.
 
I am trying to programmatically add an HttpHandlerAction, but I am recieving
a read-only error. The code I am using is basically as follows:

Dim currhandlers As System.Web.Configuration.HttpHandlerActionCollection =
CType(System.Configuration.ConfigurationManager.GetSection("system.web/httpHandlers"),
System.Web.Configuration.HttpHandlersSection).Handlers
currhandlers.Add(New System.Web.Configuration.HttpHandlerAction(mypath,
"mytype", "*", False))

What do I need to do to add an HttpHandlerAction? Any help would be
appreciated. Thanks.

Hi

According to the VS help files an HttpHandlerAction object has to be
created and initialised before it can be added to a
HttpHandlerActionCollection.

Try naming and creating the HttpHandlerAction separately like so:

Dim MyHandlerAction As HttpHandlerAction = new HttpHandlerAction
("myType","*",False)

and then adding it to the collection with.

currhandlers.Add(MyHandlerAction).

Im not sure of the reason for this but not all Add or class
constructor methods will accept a new constructor in place of a
parameter. I tend to avoid them because they can make debugging very
difficult.

HTH
 
Back
Top