Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.aspx vs .ashx MAIN difference

What are the differences between .aspx and .ashx pages? I use ashx now when I need to handle a request that was called from code and returned with a response, but I would like a more technical answer please.

like image 632
Arrabi Avatar asked Mar 29 '11 07:03

Arrabi


People also ask

What is a .ashx document?

An ASHX file is a webpage that is part of an ASP.NET web server application. It contains references to other pages hosted on the web server that are sent to the user's web browser. ASHX files are processed by the server's ASP.NET HTTP Handler when a client web browser requests the page.


4 Answers

Page is a special case handler.

Generic Web handler (*.ashx, extension based processor) is the default HTTP handler for all Web handlers that do not have a UI and that include the @WebHandler directive.

ASP.NET page handler (*.aspx) is the default HTTP handler for all ASP.NET pages.

Among the built-in HTTP handlers there are also Web service handler (*.asmx) and Trace handler (trace.axd)

MSDN says:

An ASP.NET HTTP handler is the process (frequently referred to as the "endpoint") that runs in response to a request made to an ASP.NET Web application. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page through the page handler.

The image below illustrates this: request pipe line

As to your second question:

Does ashx handle more connections than aspx?

Don't think so (but for sure, at least not less than).

like image 199
Oleks Avatar answered Oct 10 '22 00:10

Oleks


.aspx uses a full lifecycle (Init, Load, PreRender) and can respond to button clicks etc.
An .ashx has just a single ProcessRequest method.

like image 32
Hans Kesting Avatar answered Oct 09 '22 23:10

Hans Kesting


.aspx is a rendered page. If you need a view, use an .aspx page. If all you need is backend functionality but will be staying on the same view, use an .ashx page.

like image 45
Babak Naffas Avatar answered Oct 10 '22 01:10

Babak Naffas


For folks that have programmed in nodeJs before, particularly using expressJS. I think of .ashx as a middleware that calls the next function. While .aspx will be the controller that actually responds to the request either around res.redirect, res.send or whatever.

like image 34
flash Avatar answered Oct 10 '22 01:10

flash