c#下载图片

String ImgUrl2 = context.Request.QueryString["ImgUrl"];
String ImgUrl = ImgUrl2.Substring(0, ImgUrl2.Length - (ImgUrl2.Length - ImgUrl2.LastIndexOf('@')));
String ImgName = ImgUrl.Substring(ImgUrl.LastIndexOf('/')+1, ImgUrl.Length-ImgUrl.LastIndexOf('/')-1);
context.Response.ContentType = "image/jpeg";
context.Response.AddHeader("Content-Disposition", "attachment;filename=" + ImgName + "");
string filename = context.Server.MapPath(ImgUrl);
context.Response.TransmitFile(filename);
context.Response.End();

原文地址:https://www.cnblogs.com/xwchengc/p/4115165.html