【发布时间】:2015-11-20 20:31:00
【问题描述】:
为了从我的服务器下载文件,我在 asp.net MVC 中使用此方法:
string fileName = "SAMSUNG.zip";
string path = @"D:\Tutorial MVC5\ContosoUniversity\ContosoUniversity\dlfile\";
string fullPath = path + fileName;
Response.Clear();
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.ContentType = "application/x-zip-compressed";
Response.WriteFile(fullPath);
Response.End();
但是,当我想从另一台服务器下载文件时,例如从“主机下载”中下载文件时该怎么办。我怎样才能做到这一点?比如我的下载直接链接是:http://dl.test.com/file.zip,
现在用户单击链接<a href="http://test.com/1">file.zip</a> 是下载文件。现在我想将file.zip 发送给用户,而用户不知道我的可信链接在哪里以及我的主机下载在哪里。她或他只是选择要下载的文件。
感谢您的帮助!
【问题讨论】:
-
这不是 asp.net MVC 下载文件的方式。
-
你试过什么..?这并不难..你熟悉
WebClientClass..吗?我将发布一个我认为您正在尝试做的示例.. -
@user2310064 为什么不能使用示例并将 URL 作为参数传递.. 否则您希望如何将 URL 传递给最终用户..?
标签: c# asp.net-mvc download host