HttpHandler动态生成图片
2015-07-06 14:52
561 查看
在Web1站点下存一张图片1.gif:测试站点中的图片输出到Http响应输出流;
1、浏览器不知道服务器上有1.gif的存在,浏览器只是,发请求,就收请求,显示图片,其他的就是一概不知~!!(这个要想明白!!)
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; namespace Web1 { /// <summary> /// ContentTypeTest 的摘要说明 /// </summary> public class ContentTypeTest : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "image/gif"; string FilePath = context.Server.MapPath("~/1.gif"); using(Stream instream=File.OpenRead(FilePath))//new FileStream(....); { instream.CopyTo(context.Response.OutputStream); } } public bool IsReusable { get { return false; } } } }
1、浏览器不知道服务器上有1.gif的存在,浏览器只是,发请求,就收请求,显示图片,其他的就是一概不知~!!(这个要想明白!!)
相关文章推荐
- HttpResponse
- HttpRequest类
- 第 3 节: 3-Http协议之Request、Response
- HTTP协议分析
- 第 11 节: 11-HttpHandler简介
- TCP/UDP编程
- http协议分析工具
- HDOJ-1532 Drainage Ditches(网络流)
- HttpClient的使用方法
- iOS开发经验技巧之IOS中http请求使用cookie
- iOS 网络编程 socket 发送数据
- HttpClient的使用
- 影响移动应用网络性能的三大因素
- Swoole,PHP语言的高性能网络通信框架
- boost http请求应用
- 网络路径查询traceroute
- https原理及tomcat配置https方法
- TCP/IP协议详解v1(第三章IP网际协议)
- TCP/IP协议详解v1(第二章数据链路层)
- TCP/IP协议详解v1(第一章概述)