Session
A recent need to do a response to a specific request interface, only internal processing, there is no UI, the machine in this case, of course, using implementation IHttpHandler to process, you can reduce the time to load HTML controls. As it was, the two methods defined in IHttpHandler, ProcessRequest (HttpContext ctx) and Isrunable (), were seen in ProcessRequest (HttpContext CTX There is a httpcontext input parameter that could have been used for all server objects, only the previous reference to HttpContext. However, the problem arises, in this custom HTTP response processing header needs to write session, for other request and response can be referenced by the use of HttpContext, but the session is not, always appear the object is not referenced error, Really baffled, good HttpContext inside are listed in the server object can be used, but the session is not used! Really bitter, had to be custom HttpHandler content to do ordinary webform. After doing a good job, but inadvertently found in the custom HttpHandler to use the method of Session!
1, the first reference System.Web.SessionState this namespace,
2, if it is to read the content of the session in the HttpHandler, it is necessary to implement the IHttpHandler class in the same time ireadonlysessionstate this interface.
3, if it is to read and write the content of the session in the HttpHandler, it is necessary to implement the IHttpHandler class in the same time IRequiresSessionState
This allows you to use the session normally in a custom HttpHandler.