public bool IsReusable
{
Get
{
return false;
}
}
property to change the value of this property to true, why doesn't it work? As explained by MSDN, this property means:
"Gets a value that indicates whether the IHttpHandler instance can be used by other requests, or true if the IHttpHandler instance can be used again;
False ”
See this explanation maybe some students will want to set the value of this property to true, you can reuse the IHttpHandler instance to achieve the purpose of improving performance.
But even if the value of this property is set to true. It's not going to work. Today, say this attribute,
We know that *.ashx is handed to simplehandlerfactory for processing, in which the call to the GetHandler () method directly returns the corresponding instance, which is the
The IsReusable attribute is not used in simplehandlerfactory.
First, from the context in the Maphandlerexecutionstep class. Handler = this._application. Maphttphandler (Context,
Request. RequestType, request. Filepathobject, request. Physicalpathinternal, false) start looking at the Maphttphandler method,
The function is to create a HttpHandler object, expand the method has the following code to note, httphandleraction mapping =
This. Gethandlermapping (context, RequestType, Path, useappconfig), the function of this method is to request from the Method (RequestType) and path (path) to get the corresponding configuration item, and the last return type is httphandleraction
。 If you expand the Gethandlermapping method, the general work is to find it from the cache first, and then look for the corresponding mapping from the configuration file if you can't find it.
Another place in the Maphttphandler method is IHttpHandlerFactory factory = this. GetFactory (mapping); the interface creates a
HttpHandler.
We know that ASHX can handle HTTP requests directly, both of which implement the IHttpHandler interface because the configuration is complete, and the default configuration information is as follows:
<add path= "*.ashx" verb= "*" type= "System.Web.UI.SimpleHandlerFactory" validate= "true"/>
And Simplehandlerfactory also implements the IHttpHandlerFactory interface, so you can create a IHttpHandler instance based on the requested path.
HttpApplication when processing a request, it does not directly create an instance of IHttpHandler, but rather gets a IHttpHandlerFactory object first.
Call the GetHandler () method again to get a IHttpHandler instance.
Generic handler aspx