`
xuning227
  • 浏览: 74467 次
  • 性别: Icon_minigender_1
  • 来自: 新疆
文章分类
社区版块
存档分类
最新评论

httphandler ------能响应输出 http允许的所有内容

阅读更多
1.能响应输出 http允许的所有内容

2.但是一般输出 图片,视频,输出一个文件(下载)----(普通的html还是交给aspx输出)


下载一个图片:点击一个连接--弹对话框--问是否下载

 public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/html";//返回一个text的东西,也就是string
            context.Response.ContentType = "image/JPEG";
            context.Response.AddHeader("Content-Disposition", "attachment:filename=Hydrangeas.jpg");//这句话就是关键:出现对话框的关键
            context.Response.WriteFile("Hydrangeas.JPG");
           
        }

<body>
    <form id="form1" runat="server">  
     <a href="Handler2.ashx">点我啊</a>
    </form>
</body>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics