xuning227 发表于 2013-2-7 19:38:46

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>
页: [1]
查看完整版本: httphandler ------能响应输出 http允许的所有内容