Ashx vs aspx for file download?

If you want to loosely couple your download from the rest of your application, a Generic Handler is a good way to go, as you are essentially creating a service. Otherwise, if you are only planning on having that download from that button, and only that button, you can leave the logic there. Remember, there is such thing as making your application more over complex than it need be.

Good point on reuse, the functionality will not be reused in this case. The only other thing that comes to mind now whether an event handler inside an update panel can pop the download box? Perhaps I'll update the original question with this as well.

– e36M3 Dec 15 '10 at 23:21.

It's really up to you. ASHX's don't have the same page lifecycle as an ASPX (no OnLoad, etc), are generally considered to be faster due to low overhead, and don't have the extraneous markup file associated with a webform. You might also consider a web service (ASMX) if appropriate in your application.

Agreed, I know it's slimmer. Wasn't sure if there is any other benefit to go down this route. Considering that I already have a page that provides the download link, if reuse is not an issue and performance is the only other benefit than I might as well do it in an event handler on the same page.

– e36M3 Dec 15 '10 at 23:17 Using an HTTPHandler for file download isn't so much about performance or reuse. It's given a specific task, to authenticate and serve up a file and nothing else. This has no requirement for a page life-cycle, or SOAP schema's or anything like that.

Your aspx page and asmx/wcf services are effectively built on top of HTTPHandlers. I vote for using HTTPHandler for your file download. – Phill Dec 15 '10 at 23:51.

I'm using ASHX for this, since I think they have a smaller footprint and since I need no UI at all for streaming a file, these are perfect for me.

As some suggested code reuse would favor the handler, however it's not an issue in this particular case. The handler is also faster being that it avoids the page life cycle, however this slight performance improvement is probably not worth creating a handler for in my particular situation. The only thing that comes to mind now is (assuming using the same aspx page approach) whether there is any special consideration in a situation where the GridView is inside an UpdatePanel?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions