文件下载 获取远程图片

           //response.setHeader("Content-disposition","inline; filename=test1.doc"); //线上浏览方式,用IE打开
            response.setHeader("Content-disposition", "attachment; filename=test1.doc");//下载方式,下载,不用浏览器打开
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-disposition", "attachment; filename=ciwong.doc");
            string strDoc = this.RenderView("View", new Examination.Mapping.Entities.Examination() { ExaminationID = id });
            Response.ContentType = "application/ms-doc";
            Response.Write(strDoc);
            Response.Flush();
            Response.End();
            Response.Close();
 //下载远程图片
public static System.Drawing.Image DownImg(string url) { WebRequest wreq = WebRequest.Create(url); wreq.Timeout = 10000; HttpWebResponse wresp = (HttpWebResponse)wreq.GetResponse(); Stream s = wresp.GetResponseStream(); System.Drawing.Image img = System.Drawing.Image.FromStream(s); img.Save(filename, ImageFormat.Jpeg); img.Dispose(); s.Dispose(); return img; }

 

           //response.setHeader("Content-disposition","inline; filename=test1.doc"); //线上浏览方式,用IE打开
            response.setHeader("Content-disposition", "attachment; filename=test1.doc");//下载方式,下载,不用浏览器打开
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-disposition", "attachment; filename=ciwong.doc");
            string strDoc = this.RenderView("View", new Examination.Mapping.Entities.Examination() { ExaminationID = id });
            Response.ContentType = "application/ms-doc";
            Response.Write(strDoc);
            Response.Flush();
            Response.End();
            Response.Close();

posted @ 2012-12-06 13:57  Rhythmk  阅读(204)  评论(0编辑  收藏  举报
Rhythmk 个人笔记