tags:

views:

338

answers:

5

I've been using user controls extensively but never use a HttpHandler and was wondering if I am doing something suboptimal or wrong

+6  A: 

Unfortunately your question is a little like "Should I use a sandwich or a cement mixer". HttpHandlers and User controls are completely different things.

HttpHandlers are used to process HTTP requests. For example, if you wanted to dynamically create an RSS feed, you could write an HTTP handler that handles all requests for ".rss" files, creates the output and sends it back to the user.

User controls are used within ASPX pages to encapsulate units of functionality that you want to re-use accross many pages.

Chances are, if you're using user controls successfully, you don't want to use HttpHandlers!

Chris Roberts
A: 

Even an Asp.Net page is an HttpHandler.

public class Page : TemplateControl, IHttpHandler

A user control actually resides within the asp.net aspx page.

Vaibhav
A: 

Expect a better answer (probably before I finish typing this) but as a quick summary.

A user control is something that can be added to a page.

A HttpHandler can be used instead of a page.

Matt Lacey
+1  A: 

Basically a user control is a piece of server logic and UI. An HTTP Handler is only a piece of logic that is executed when a resource on your server is requested. For example you may decide to handle requests for images sent to your server through your own handler and serve images from a database instead of the file system. However, in this case there's no interface that the user sees and when he visits a URL on your server he would get the response you constructed in your own handler. Handlers are usually done for specific extensions and HTTP request types (POST, GET). Here's some more info on MSDN: http://msdn.microsoft.com/en-us/library/ms227675(VS.80).aspx

Slavo
A: 

Just to clarify the question. I was reading the Hanselman post http://www.hanselman.com/blog/CompositingTwoImagesIntoOneFromTheASPNETServerSide.aspx and thinking that I would never solved the problem with a HttpHandler, maybe with a simple page returning a binary content.

This led me to think that I should add HttpHandler to my developer tool belt.

Eduardo Molteni