0

In an ASP.NET MVC3 application

I have an Action method that returns a file for the user to download.

In the HomeController:

[HttpGet]
public ActionResult DownloadFile()
{
    pathToReturn = FileManager.GetPathOfFile();
    return File(pathToReturn, Path.GetFileName(pathToReturn));
}

I call it when he clicks a button in the view:

<input type="button" onclick="window.location.href='@Url.Action("DownloadFile", "Home")';" value="Download File"/>

How can I access this action from the address bar? (I want to remove the button)

what is the url for that action? (What should I type in the address bar in order for the file to be downloaded? is this possible to do?

Thanks

Y2theZ
  • 10,162
  • 38
  • 131
  • 200

2 Answers2

0

Let say that it depends on your routing rules... but supposing you're using the default ones, you should access to your action with the url:

http://yourserver/yourapplication/Home/DownloadFile
themarcuz
  • 2,573
  • 6
  • 36
  • 53
0

http://yourserver/home/DownloadFile

provided that routing you have not changed

Mediator
  • 14,951
  • 35
  • 113
  • 191