Reputation: 15598
I understand that the http handlers process request but this is just theory as I don't understand it. Many 3rd party controls require adding a http handler in web.config. And sometimes we are required to create our own class with ProcessRequest method that implements IHttpHandler interface but I am confused to understand where Http handler fits in and what their roles are?
Upvotes: 4
Views: 1967
Reputation: 1062770
Http handlers are an essential part of ASP.NET - they are what handles the request and generates the response. In webforms it is typical for a page (aspx, or maybe ashx) to interpret a request, but this is itself a type of handler (just mapped by default in the main web.config file).
In the case of adding handlers to the config file, this is typically because the application is generating content dynamically for urls that don't magically map to existing files, or to add some logic for files that do exist but which are beyond regular asp.net.
If you are using ASP.NET MVC, you tend to need this much less (if at all) as it is the norm for requests not to map directly to an aspx/ashx in the source tree.
Thinking back to ASP.NET webforms, the main time I've used handlers is when doing things like binary downloads, file exports, etc - where I don't really want it running through the webforms aspx pipeline.
Upvotes: 5
Reputation: 2368
Personally, I use them for handling all my AJAX requests. Because i'm usually outputting XML/ JSON, I use a handler so I don't have to worry about all the overheads that come with implementing System.Web.UI.Page.
They also allow you to intercept the HTTP pipeline, which can be useful at times. I think it all depends on what you're trying to achieve.
Sean
Upvotes: 0