|
HttpHandler实现了ISAPI Extention的功能,他处理请求(Request)的信息和发送响应(Response)。HttpHandler功能的实现通过实现IHttpHandler接口来达到。
看图先:
在ASP.NET 管道处理的末端是HTTP Hander,其实每个Asp.net的Page都实现了IHttpHander,在VS.net中的对象察看器中你可以证实这一点
具体的类是这样定义的:public class Page : TemplateControl, IhttpHandler。
接口IHttpHandler的定义如下:
interface IHttpHandler
{
void ProcessRequest(HttpContext ctx);
bool IsReuseable { get; }
}
接口中ProcessRequest是添加自己的代码进行相应处理的地方。IsReuseable属性指明该HttpHandler的实现类是否需要缓存。
在CS中有很多继承IHttpHandler接口的类,我取出有代表性而又容易理解的一个做分析:找到CommunityServerComponents项目Components目录下的Redirect.cs文件,内容如下:
//------------------------------------------------------------------------------ // <copyright company="Telligent Systems"> // Copyright (c) Telligent Systems Corporation. All rights reserved. // </copyright> //------------------------------------------------------------------------------
using System; using System.Web;
namespace CommunityServer.Components { /**//// <summary> /// Summary description for Redirect. /// </summary> public class Redirect : IHttpHandler { public Redirect() &nb [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>
|