Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


.NET custom/user controls, web services and httphandlers

Posted on 2002-05-26
Medium Priority
Last Modified: 2013-11-25
questions on these 4 .NET topics: custom controls, user controls, web services, httphandlers.

pleaes answer all:

1. can't they all, or several of them, be used to basically perform the same task?
2. what really makes them different/unique besides the obvious?
3. what are some simple "real-world" ideas/examples for each one that would illustrate:

a. how they are different, if at all.
b. how they can be used together to perform some kind of simple web solution.

if possible, examples from your own experience with using them would be ideal.

thank you!
Question by:loyaliser
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 23

Accepted Solution

naveenkohli earned 800 total points
ID: 7035752
all four of these are totally diferent creatures.

UserControl - It is a custom control but it inherits a lot of attributes from base classes. The example will be a composite control. Where you derive a control like LoginBox. This box will host 2 text and 2 label control and a button. And you can use this user control on your pages as a one single enity. The documentation has an example for this control.

Custom Control - Its a control that is derived from Control class. And does not inherit whole lot of attributes (Properties, Events, Method) implementatios from base classes as compared to UserControl. The big difference is that you will be responsible for emitting the HTML stream for this control. You will not be aggregating any existing control. Nothing stops you from that, but the whole idea behind a Custom Control is to develop a control from scratch. Take a look at the folloing link. Its custom "UpDown" control. It emit its own HTML stream in Render method.

HtppHandlers - They are equivalent of ISAPI extensions. They provide you low level access to actual HTTP request and response. They are utilized for processing the requests before they get to the ASP.Net page processing. All the operations in ASP.Net framework happens through HttpHAndlers. Take a look at Machine.config file. You will find a whole bunch of HttpHAndlers defined there. Here are couple of examples SessionStateSectionHandler, CompilationConfigurationHandler, etc. You can create an object implementing IHttpHandler interface. Then you register this handler with framework through web.config file. What will happen is that your handler will get chance to process the request in ProcessRequest method. There you can modify the request. For example in FormAuthentication, the handlers process the request and check presence of authentication tickets. Based on that tests, the user is redirected to appropriate pages.

WebServices - I don't know how should I describe them in short. They are a topic in itself. Consider it like a service provided over the internet. For example I have a service that processes image geenration requests. The caller sends me the data for rendering images in XML string format. My web service (ASP.Net , asmx file) recieves the request and processes the input information, renders the image and sends the output stream to caller. Its like invoking a remote component over the internet. The difference is that the service publishes it capabilities throough WSDL files instead of a typelib or IDL file incase of COM object. I think documentation will give you more insight into this.

So you can see that all 4 creatures a totaly different used for diferent purposes.


WebServices - These are a

Author Comment

ID: 7035840

i understand the UserControl perspective... the idea of making web sites modular - just like the IBuySpy.com sample web site. very neat and clear usage.

clearly, UserControls are being used because it is a matter of new design structure for web sites using ASP.NET. that i understand.

CustomControls and HttpHandlers:

when it comes to CustomControls and custom HttpHandlers, i am at a loss as to what "the motivating factors" are behind using them?

that is my main confusion... when do i know that i need to, or should, use them?

Web Services:

ok... the idea of some internet-based service that returns data to user/server based on some input it receives makes sense... like a news web service that consumes date ranges, and produces news articles in XML format within those date ranges.

but question with this is: can't the same effect be created using Custom or UserControls?

if so, how do i know which of the 3 to use?

thank you.
LVL 23

Expert Comment

ID: 7035920
As I mentioned earlier, you will use Custom Controls for purposes where the existing web server controls don't serve the puspose. The example I gave of UpDownControls. There is no control in library that will provide this functionality. So the only option you have in that case is develop your own control. Conside them like Owner Drawn controls in MFC where you have to do all the painting your self. Its the same way. In custom controls you will do all the redenring. Another example of custom control is Tree control. There is a web control that serves the purpose. But that onlt works for IE. So for browser independent implementation, you will have to create your own Custom tree view control. And similarly creating Menu controls.

HttpHandlers have nothing to do with server controls. Normally you don't require to implement HttpModules. Like you very rarely create ISAPI extensions. Here is an example from documentation.
           <add verb="*" path="*.jpg"
                type="JpegFileHandler,httpruntime" />
This configuration indicates that if anybody requests a file with extension .jpg, the JpegFileHandler HttpHandler should process the request. And in your processRequest of this httphandler, you can pre-process the information. So If your application plicy does not allow some user to get JPG file, you can end the response there and don't let it get the file.

Then to go a level lower, you can implement HttpModules. They are equivalent to ISAPI filters.

On the same note, WebService have nothing to do with controls.

UserControls are pages initeself. You can assemble other server controls in the user control to build a module so that you can provide uniform look and feel to the site. For example building Header, Footer, TopMenu, LeftMenu, MainBody templates as UserControls. And then on each page you can load these user controls to have same look.

Use CustomControls to enhance functionlity of exsiting server control or develop something that does not exist.


Author Comment

ID: 7035947
good thanks... it is making more sense now...

the techicals are easy to grasp... just needed to get the idea/logic behind these things down, so i'll know what to do with them when the time comes.


Author Comment

ID: 7035948
good thanks... it is making more sense now...

the techicals are easy to grasp... just needed to get the idea/logic behind these things down, so i'll know what to do with them when the time comes.


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question