Overview
HttpHandler是一个HTTP请求的真正处理中心,也正是在这个HttpHandler容器中,ASP.NET Framework才真正地对客户端请求的服务器页面做出编译和执行,并将处理过后的信息附加在HTTP请求信息流中再次返回到HttpModule中。
What is IHttpHandler
IHttpHandler在MSDN中的定义:使用自定义的HTTP处理程序同步处理HTTP Web请求而实现的协定。(注意:如果是异步的话就要使用IHttpAsyncHandler接口)
IHttpHandler定义了如果要实现一个HTTP请求的处理所必需实现的一些系统约定。HttpHandler与HttpModule不同,一旦定义了自己的HttpHandler类,那么它对系统的HttpHandler的关系将是“覆盖”关系。
IHttpHandler包含一个属性IsReusable,用于获取当前IHttpHandler实例是否可用,一般设置为true;一个方法ProcessRequest(HttpContext context),进行实际的操作过程。
How IHttpHandler handles HTTP requests
当一个HTTP请求经过HttpModule容器传递到HttpHandler容器中时,ASP.NET Framework会调用HttpHandler的ProcessRequest成员方法来对这个HTTP请求进行真正的处理。
flow chart
The meaning of each attribute in the httpHandlers node
The Verb attribute
specifies the HTTP actions supported by the handler. "*" supports all HTTP actions; "GET" supports Get operation; "POST" supports Post operation; "GET, POST" supports two kinds of operations
Path attribute
specifies the path and file name of the handler to be called (can include universal character)." ", " .aspx"
Type
attribute specifies the actual type of the handler or handler factory with a combination of namespace, class name and assembly name. The ASP.NET runtime first searches for DLLs in the bin directory, Then search in the GAC
Configuration in Web.Config
Select the generic handler and enter a name as shown:
The original code you see after creating the file, as shown in the figure:
IRequiresSessionState, the interface used to read the Session value; context.Response.Write("Hello World") return value
learning materials
1.1 Asynchronous HttpHandler implementation in ASP.NEThttp
: //www.hello-code.com/blog/asp.net/201512/5793.html
1.2 Understanding and deepening understanding of HttpHandlerhttp:
//www.cnblogs.com/whtydn/archive/2009/10/19/1585778.html
1.3 What is HttpHandler
http://www.studyofnet.com/news/378.html