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
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: