我有一个控制器和下载文件的方法。没有代码,我需要的只是去这个链接:从我的项目中下载文件
http://localhost:1186/Content/MyFolder/file1.exe
和文件被下载。
我试着用代码来做到这一点是这样的:
Response.Redirect(Server.MapPath("~\\Content\\MyFolder\\file1.exe"));
但断点通过此行并没有任何反应。我认为问题是我正在使用Server.MapPath,但我还会如何做到这一点?
Server.Ma pPath返回资源的物理路径,请尝试Response.Redirect(“〜\\ Content \\ MyFolder \\ file1.exe”); – MSUH
此相关的有关下载使用MVC文件可能是有用的,这样的问题,http://stackoverflow.com/questions/5826649/returning-a-file-to-view-download-in-mvc – Despertar