zoukankan      html  css  js  c++  java
  • 使用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);
            }

        }

    }
  • 相关阅读:
    Linux 下 MQ 的安装
    云计算的三种服务模式:IaaS,PaaS和SaaS
    Mac下安装Maven
    JDK Mac 安装
    Mac OS 终端利器 iTerm2
    单元测试用例规范
    boolean 属性的定义规范
    2019-12-9号 终于入职 阿里巴巴
    远程调试方法
    系统提测及上线规范(系统上线必读!)
  • 原文地址:https://www.cnblogs.com/mobile/p/608861.html
Copyright © 2011-2022 走看看