Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Registered HttpHandlers in the Web.Config from HttpContext

Tags:

asp.net

Is there a way to get the types of the registered IHttpHandlers from a current HttpContext or the web.config?

I'm trying to see if my HttpHandler is registered in the web.config from a WebControl.

like image 809
Daniel A. White Avatar asked Aug 16 '11 19:08

Daniel A. White


People also ask

How do I add httpHandlers to Web config?

config file, create a handlers element in the system. webServer section. Handlers that are defined in the httpHandlers element are not used. If you do not remove the httpHandlers registrations, you must set the validation element's validateIntegratedModeConfiguration attribute to false in order to avoid errors.

How are httpHandlers gets configured?

To create a custom HTTP handler, you create a class that implements the IHttpHandler interface to create a synchronous handler. Alternatively, you can implement IHttpAsyncHandler to create an asynchronous handler. Both handler interfaces require that you implement the IsReusable property and the ProcessRequest method.

What are httpHandlers in MVC?

- An HTTP handler is the process, also called the endpoint, that runs in response to a request. It's used to handle specific requests based on file extensions and verbs. You can leverage these handlers to inject processing logic into the request pipeline.

Which of the following elements registers the custom handler?

The configuration element registers the custom handler factory by class name and maps the . sample file name extension to that handler. Because you are registering a custom file name extension, you register the handler in both the handlers section and the httpHandlers section.


1 Answers

You can get the list of registered HttpHandlers from web.config this way:

using System.Configuration;
using System.Web.Configuration;

Configuration cfg = WebConfigurationManager.OpenWebConfiguration("/");
HttpHandlersSection hdlrs = (HttpHandlersSection)cfg.GetSection("system.web/httpHandlers");
like image 200
Ofer Zelig Avatar answered Nov 15 '22 05:11

Ofer Zelig



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!