Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ashx vs aspx for file download

In a basic scenario where I have a GridView with files to download and link buttons to download them, is there any benefit at all for creating a custom http handler for streaming those files as opposed to simply streaming from the event handler of the download link button?

Edit:

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?

like image 522
e36M3 Avatar asked Dec 15 '10 22:12

e36M3


People also ask

What kind of files are ASHX files?

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.

What is download ASHX?

A file with the ASHX file extension is an ASP.NET Web Handler file that often holds references to other web pages used in an ASP.NET web server application.

What is ASPX file?

Active Server Pages (ASPX) is a file format used by web servers and generated using the Microsoft ASP.NET framework - an open-source development framework used by web developers to create dynamic web pages, often with the . NET and C# programming languages.

How do I install an ASHX file?

For adding ashx file follow below steps. Right click on Project. Select Add from the menu. In Add New Item dialog window select Generic Handler and click on Add.


1 Answers

Are you planning on reusing the functionality of your download from more than one spot within your application? 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.

like image 75
George Johnston Avatar answered Sep 24 '22 02:09

George Johnston