Programmatically adding an HttpHandlerAction

  • Thread starter Nathan Sokalski
  • 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.
 
S

Stan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top