HttpHandler动态生成图片
生活随笔
收集整理的這篇文章主要介紹了
HttpHandler动态生成图片
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在Web1站點下存一張圖片1.gif:測試站點中的圖片輸出到Http響應輸出流;
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的存在,瀏覽器只是,發請求,就收請求,顯示圖片,其他的就是一概不知~!!(這個要想明白!!)
轉載于:https://www.cnblogs.com/xcl461330197/articles/4539766.html
總結
以上是生活随笔為你收集整理的HttpHandler动态生成图片的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 寻找道路(codevs 3731)题解
- 下一篇: MFC UI按钮多线程