⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 outstream.ashx

📁 一个不错的在线考试系统!~~实现了基本的在线考试系统的主要功能
💻 ASHX
字号:
<%@ WebHandler Language="C#" Class="OutStream" %>

using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using netextramSystem;

public class OutStream : IHttpHandler {
    private SqlDbBase Db = new SqlDbBase();
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "image/jpeg";
        context.Response.Cache.SetCacheability(HttpCacheability.Public);
        context.Response.BufferOutput = false;
        string loginID=null;
        string type=null;
        Stream stream = null;
        if (context.Request.QueryString["id"] != null && context.Request.QueryString["type"] != null)
        {
            type = context.Request.QueryString["type"];
            loginID = context.Request.QueryString["id"];
            switch(type)
            {
                case "1":
                    stream = Db.RunScalar("photo","tb_stuinfo_学生","stuID='" + loginID + "'",null);
                    break;
                case "2":
                    stream = Db.RunScalar("photo", "tb_teachinfo_教师", "teachID='" + loginID + "'", null);
                    break;
                case "3":
                    stream = Db.RunScalar("photo", "tb_admininfo_管理员", "admID='" + loginID + "'", null);
                    break;                 
            }
        }
        if (stream != null)
        {
            //定义字节缓存空间
            const int buffersize = 1024 * 200;
            byte[] buffer = new byte[buffersize];
            int count = 0;
            count = stream.Read(buffer, 0, buffersize);
            while (count > 0)
            {
                context.Response.OutputStream.Write(buffer, 0, count);
                count = stream.Read(buffer, 0, buffersize);
            }
        }
    }
 
    public bool IsReusable {
        get {
            return true;
        }
    }
    

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -