asp.net 下载图片
public class DownLoad : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string fileName = context.Request.QueryString["filename"]; //火狐浏览器支持中文传输,编码后反倒不认了,所以要判断排除火狐浏览器再编码 string UserAgent = context.Request.ServerVariables["http_user_agent"].ToLower(); if (UserAgent.IndexOf("firefox") == -1) {//非火狐浏览器 fileName = HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8); } context.Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName); context.Response.WriteFile(context.Server.MapPath("Down/") + context.Request.QueryString["filename"]); //这里一定要未编码的文件名字。否则找不到文件 } public bool IsReusable { get { return false; } } }