欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【ashx文件的使用小结】,下面是详细的讲解!
ashx文件的使用小结
<%@ 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;
PhotoSize size;
switch (context.Request.QueryString["Size"]) {
case "S":
size=PhotoSize.Small;
break;
case "M":
size=PhotoSize.Medium;
break;
case "L":
size=PhotoSize.Large;
break;
default:
size=PhotoSize.Original;
break;
}
Int32 id=-1;
Stream stream=null;
if (context.Request.QueryString["PhotoID"] !=null && context.Request.QueryString["PhotoID"] !="") {
id=Convert.ToInt32(context.Request.QueryString["PhotoID"]);
stream=PhotoManager.GetPhoto(id, size);
} else {
id=Convert.ToInt32(context.Request.QueryString["AlbumID"]);
stream=PhotoManager.GetFirstPhoto(id, size);
}
if (stream==null) stream=PhotoManager.GetPhoto(size);
const int buffersize=1024 * 16;
byte[] buffer=new byte[buffersize];
int count=stream.Read(buffer, 0, buffersize);
while (count > 0) {
context.Response.OutputStream.Write(buffer, 0, count);
count=stream.Read(buffer, 0, buffersize);
}
}
}
关于ashx文件的使用小结的用户互动如下:
相关问题:
答: >>详细
相关问题:
答: >>详细
相关问题:
答: >>详细
- 【asp】asp.net url重写浅谈-net-url重写
- 【DataSet】DataSet、DataTable、DataRow区别详解
- 【asp】asp.net 动态添加多个用户控件-net-动态添
- 【创建】ASP.NET Web API教程 创建域模型的方法详
- 【Asp】Asp.net 页面调用javascript变量的值-net-
- 【ASP】ASP.NET 5升级后如何删除旧版本的DNX-NET5
- 【asp】asp.net ubb使用代码-net-ubb使用
- 【默认图片】图片不存在使用默认图片代替的实例
- 【asp】asp.net 页面转向 Response.Redirect Ser
- 【jQuery】jQuery实现倒计时跳转的例子-倒计时跳
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
