Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between ASP.net Handler and Generic Handler

Tags:

c#

.net

asp.net

When we add a new item to an ASP.NET web application project in Visual Studio 2010, I have noticed two templates:

  1. ASP.NET Handler
  2. Generic Handler

What is the difference between these two and when are they used?

like image 775
Sravan Kumar Avatar asked Feb 13 '13 12:02

Sravan Kumar


People also ask

What is generic handler in asp net?

ASHX Generic Handler is a concept to return dynamic content. It is used to return ajax calls, image from a query string, write XML, or any other data.

What is the use of .ashx file in asp net?

What is an ASHX file? An ASHX file is a webpage that is used by the ASP.NET HTTP Handler to serve user with the pages that are referenced inside this file. The ASP.NET HTTP Handler processes the incoming request, references the pages from the . ashx file, and sends back the compiled page back to the user's browser.

Where we can define the generic handler?

Generic handler is a dynamic file and is generated with c# code and disk resource. Generic handler do not have web forms. Generic handler is also known as ASHX generic handler. It is useful when we want to return image from a query string,write XML and other Data.

What is the use of Httphandlers?

An HTTPhandler may be defined as an end point that is executed in response to a request and is used to handle specific requests based on extensions. The ASP.Net runtime engine selects the appropriate handler to serve an incoming request based on the file extension of the request URL.


1 Answers

Generic handler:

Generic Handler is a default handler which will have @webhandler directive and has .ashx extension this generic handler is not having UI but it provides response when ever any request made to this handler.

HTTP Handler:

HTTP Handler is a process which runs and continue to server request and give response based on the request handling code. This handler does not have UI and need to configured in the web.config against extensions. One of the great example of Http Handler is page handler of ASP.NET which serves .aspx pages request.

The Main difference between Generic and HTTP handler is

Generic handler has a handler which can be accessed by url with .ashx extension while http handler is required to be configured in web.config against extension in web.config.It does not have any extension.Typical example of generic handler are creating thumbnails of images and for http handler page handler which serves .aspx extension request and give response.

To know more refer this link

like image 98
coder Avatar answered Sep 18 '22 18:09

coder