直接上代码很简单返回流就客户端就会自动下载
#region 下载
string url = methodParameter[0];//传递参数要获取的图片路径
string path = url.ToString();
//获取本地项目路径
string strpath = Path.Combine(OpenWebGIS.LiquidGIS.Common.Helper.PathHelper.BaseConfigurationPath);
path = strpath + path;
System.IO.FileInfo lFileInfo = new System.IO.FileInfo(path);
context.Response.ContentType = "application/octet-stream";
context.Response.AddHeader("Content-Disposition", string.Concat("attachment;filename=", System.Web.HttpUtility.UrlEncode(lFileInfo.Name, Encoding.UTF8).Replace("+", "%20")));
context.Response.WriteFile(path);
#endregion