• 使用handler"不落地"返回图片信息


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

    using System;
    using System.IO;
    using System.Web;

    public class Handler : IHttpHandler {

        
    public bool IsReusable {
            
    get {
                
    return true;
            }

        }

        
        
    public void ProcessRequest (HttpContext context) {
            context.Response.ContentType 
    = "image/jpeg";
            context.Response.Cache.SetCacheability(HttpCacheability.Public);
            context.Response.BufferOutput 
    = false;
            
            
    try
            
    {
                
    string sno = context.Request.QueryString["sno"];

                
    byte[] buffer = GetPhoto(sno);

                
    if (buffer != null)
                
    {
                    context.Response.OutputStream.Write(buffer, 
    0, buffer.Length);
                }

                
    else
                
    {
                    context.Response.WriteFile(
    "Images/nophoto.jpg");
                }

            }

            
    catch (Exception ex){
                context.Response.Write(ex);
            }

        }

    }
  • 相关阅读:
    Java对MongoDB的CRUD
    MongoDB数据库基本用法
    MySQL order by 排序结果不正确
    Linux shell 脚本 eq,ne,le,ge,lt,gt意义
    Linux shell 命令运行符 &,;,&& 区别
    Linux netstat 命令详解
    Linux ss 命令详解
    Linux sort 命令详解
    Linux sed 命令详解
    Linux xargs 命令详解
  • 原文地址:https://www.cnblogs.com/mobile/p/608861.html
Copyright © 2020-2023  润新知