I have a scenario where the user have the option to click the button “download” and I should create a csv file, that contains history data, and then let the user save the file locally. As I haven’t done this before, I started to look around for how to do this and basically came across both Custom View Engine, and Custom Action Result.
My question now is what is the benefit/disadvantages with these? What is the preferred way to go?
The CSV file, is basically just containing headers, and data (up to about 15 columns/fields) with a few thousand rows. so nothing special really.
I would probably go for a custom action result (the actual serialization in my example is done with FileHelpers):
You could even prettify this return statement (generics are ugly and superfluous in this case) by using an extension method:
and then simply: