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);
            }

        }

    }
  • 相关阅读:
    剑指offer字符串列表
    剑指offer数组3
    剑指offer数组2
    剑指offer数组1
    剑指offer数组列表
    tensorflow+ssd_mobilenet实现目标检测的训练
    Win7+keras+tensorflow使用YOLO-v3训练自己的数据集
    Java是如何实现跨平台的
    Xshell 、PuTTY 复制文件到Linux
    Asp.Net Core2.0在linux下发布
  • 原文地址:https://www.cnblogs.com/mobile/p/608861.html
Copyright © 2011-2022 走看看