码迷,mamicode.com
首页 > 其他好文 > 详细

下载图片

时间:2017-06-30 17:06:42      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:addheader   ast   color   htm   ica   create   link   string   nload   

 public ActionResult Download(string url)
        {
            Response.AddHeader("content-type", "application/application/x-msdownload");
            Response.AddHeader("Content-Disposition", "attachment;filename=" + url.Split(/).Last());
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            WebResponse response = request.GetResponse();
            Stream resStream = response.GetResponseStream();
            return File(resStream, response.ContentType);
        }
  @Html.ActionLink("下载", "Download", new { url = "http://h.hiphotos.baidu.com/baike/s%3D220/sign=eb8c4e58a2cc7cd9fe2d33db09002104/d009b3de9c82d1588b9c0c04810a19d8bc3e426c.jpg" })

 

下载图片

标签:addheader   ast   color   htm   ica   create   link   string   nload   

原文地址:http://www.cnblogs.com/ningyouyou/p/7099156.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!