Ashx vs aspx to download a file

In the base scenario, where I have a GridView with files to download and links to buttons to load them, is there any use at all for creating a custom HTTP handler for streaming these files, and not just streaming from a link button event handler for downloads?

Edit:

Since some suggested code reuse will help the handler, however, this is not a problem in this particular case. A handler is also faster because it avoids the page life cycle, however this small performance improvement is probably not worth creating a handler in my specific situation.

The only thing that comes to mind now (when using the same approach to the aspx page) is there any special attention in the situation when the GridView is inside the UpdatePanel?

+5
source share
3 answers

Are you planning to reuse the functionality of your download from more than one place in your application? If you want to freely link your download to the rest of the application, Generic Handlerthis is a good way, since you are essentially creating a service. Otherwise, if you plan to only download this button from this button and only this button, you can leave the logic there. Remember that there is such a thing that makes your application more complex than necessary.

+4

. ASHX , ASPX ( OnLoad ..), - , -.

- (ASMX), .

+3

ASHX , , , , .

+2

All Articles