Review general handling procedures

When I was helping my classmates to answer a question today, it involved general processing procedures (the link at the end talks about IHttpHandler pipeline processing).

In the general handler, there is IsReusable, Baidu translation: reusable

The IsResuable attribute indicates whether it can be reused for other IHttpHandler instances;

If set to true, it can improve performance, but pay attention to security issues between threads; if set to false, threads are safe

Under normal circumstances, it will be set to false. Although it is not the best performance, it is the safest (anyway, it is set to false, which is to ensure safety and so on;)
1 public bool IsReusable
2         {
3             get
4             {
5                 return false;
6             }
7         }

When we open a web page, no matter whether the requested resource is static or dynamic, IIS will, according to the ISAPI (API standard on web servers jointly proposed by Microsoft and Process Software Corporation), the requested file according to the file suffix. Different names are passed to different handlers. Open IIS and you can see that most of the files are handed over to aspnet_isapi.dll for processing, but it is impossible for aspnet_isapi.dll to process all files in the same way.

To see how aspnet_isapi.dll is further processed, we can open the C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\Web.config file. As you can see, different file types are mapped to different handlers in the <httpHandler> node for processing;

 

The general html file request background can request the general handler;

The start function of a general handler is:

1  namespace WebApplication1
 2  {
 3      ///  <summary> 
4      /// It usually implements the IHttpHandler interface, because it does not have to inherit from the Page class,
 5      /// There are not so many events to be processed, and it does not need to consume too many resources, so the performance aspect 6      higher than aspx
 ///  </summary> 
7      public  class Handler1 : IHttpHandler
 8      {
 9  
10          // Although the ProcessRequest method has no return value, we can pass context.Response.Write("string type") to External input data
 11          // There is also this method, which is the 'main function' of the program, and the operation of the program is started from here; 
12          public  void ProcessRequest(HttpContext context)
 13          {
 14             context.Response.ContentType = "text/plain";
15 
16             context.Response.Write("Hello World");
17         }
18 
19         public bool IsReusable
20         {
21             get
22             {
23                 return false;
24             }
25         }
26     }
27 }
View Code

 

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325022274&siteId=291194637