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?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With