Reputation: 83
I have a Controller with a method Foo that should return a CSV file:
public class MyController : Controller
{
public FileResult Foo(string arg1)
{
return new FileContentResult(some byte[], "text/csv");
}
}
This works, if a browser hits my url /My/Foo it pops up a download dialog, but the file name it uses is the url - so it prompts the user to download "Foo".
Can I somehow use routing or config to create a '.csv' extension on this? i.e. so that /My/Foo.csv would work the same way?
Upvotes: 1
Views: 170
Reputation: 83
I was able to do this by adding a custom route:
routes.MapRoute("renamed", "my/foo.csv/{id}", new { controller = "my", action = "foo", id
Upvotes: 2