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.
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:
As to your second question:
Does ashx handle more connections than aspx?
Don't think so (but for sure, at least not less than).
-
thank you, but you didnt mention the ashx handler, what about its Request Pipe Line ? – Arrabi Mar 29 '11 at 10:46
-
1@Arrabi, `HttpHandler` is just a *section* of the request which is being executed before `Page` section. – Oleks Mar 29 '11 at 11:03
.aspx
uses a full lifecycle (Init
, Load
, PreRender
) and can respond to button clicks etc.
An .ashx
has just a single ProcessRequest
method.

- 31,955
- 11
- 77
- 132

- 38,117
- 9
- 79
- 111
-
-
11That the web server is not obligated to create a new object instance per new request. If IsReusable=true on the Handler, then the server may reuse existing handler objects to process next requests – quetzalcoatl Feb 14 '13 at 13:04
-
2So it creates an instance of handler and keeps in the memory to reuse it. It never give it back to GC. – uzay95 Jan 24 '17 at 13:02
.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.

- 3,769
- 2
- 30
- 33

- 12,395
- 3
- 34
- 49
-
that I know, I wanted more technical answer maybe with numbers, does ashx handle more connection than aspx ? – Arrabi Mar 29 '11 at 08:26
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.

- 1,663
- 16
- 16