Solved

.NET custom/user controls, web services and httphandlers

Posted on 2002-05-26
5
272 Views
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!
0
Comment
Question by:loyaliser
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
naveenkohli earned 200 total points
Comment Utility
loyaliser,
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.
http://www.pardesiservices.com/Softomatix/UpDownControl1.asp

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.

Naveen

WebServices - These are a
0
 
LVL 1

Author Comment

by:loyaliser
Comment Utility
okay...

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.
0
 
LVL 23

Expert Comment

by:naveenkohli
Comment Utility
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.
-------------
<configuration>
    <system.web>
        <httpHandlers>
           <add verb="*" path="*.jpg"
                type="JpegFileHandler,httpruntime" />
        </httpHandlers>
    </system.web>
</configuration>
---------------
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.


Naveen
0
 
LVL 1

Author Comment

by:loyaliser
Comment Utility
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.

thanks.
0
 
LVL 1

Author Comment

by:loyaliser
Comment Utility
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.

thanks.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now