![](/img/trans.png)
[英]download file from url on other Server "Host Download" - asp.net mvc
[英]how to download file from other server using mvc asp.net
我如何從其他服務器下載文件並使用帶有c#的mvc asp.net自己保存文件?
不過,我只能閱讀您的標題:
WebClient client = new WebClient();
client.DownloadFile("http://your-address.com/FileToDonwload.ext", "c:\PathToTheFileToCreate");
應該做你想要的。
我會沿着以下幾行使用System.Web.Mvc.FilePathResult :
// most controller logic ommitted
public ActionResult DownloadFile(int fileID)
{
// in this example fileID would map to a file location in the database
var item = _repository.GetByKey(fileID);
// item.DocType would equal "application/msword" / "image/jpeg" etc, etc;
return File(item.DocumentLocation, item.DocType);
}
[edit] -糟糕,您剛剛意識到這只能在相同的服務器/域上使用,但僅供參考
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.