Nate
Nate

Reputation: 83

IIS MVC Controller with period in name

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

Answers (1)

Nate
Nate

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

Related Questions