<%@ WebHandler Language="C#" Class="_05_download" %>

using System;
using System.Web;

public class _05_download : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";

        string url = context.Request.QueryString["url"];

        //解决 中文名乱码的问题
        string name = HttpUtility.UrlEncode(url);
        
        context.Response.AddHeader("Content-Disposition", "attachment;filename=" + name);

        string path = context.Request.MapPath(url);

        context.Response.WriteFile(path);
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}

 

相关文章:

  • 2022-12-23
  • 2022-02-10
  • 2021-05-22
  • 2021-08-16
  • 2021-07-11
  • 2022-12-23
  • 2021-07-16
  • 2021-11-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
相关资源
相似解决方案