ASP. NET asynchronous processing 1 (Session processing), asp. netsession
Generally, when we use ajax to process user information, the Session value cannot be found. Why?
The so-called page is a processing program, and its implementation is very complicated. It needs to be processed through the asp.net pipeline. Generally, the processing program also needs to filter the MPs event to generate HTML and submit it to the browser, but the general processing program. the ashx page only inherits the IHttpHandler interface and cannot pass sessions. What should I do if I want to intercept the Session object Value of HttpContext context?
Public class CustomerPhoto: IHttpHandler
Solution:
First, the ashx page does not directly inherit from the aspx page. We can directly obtain the Session through the page implementation interface, while the ashx page only inherits the IHttpHandler's Session object to intercept the HttpContext context and must implement the IRequiresSessionState, the using System of the imported program. web. sessionState; Use context. session object. In this way, the Session value is obtained.
Public class CustomerPhoto: IHttpHandler, System. Web. SessionState. IRequiresSessionState
Public void ProcessRequest (HttpContext context) intercepts the session value in the passed context.
Public void SavePic ()
{
HttpContext ctx = HttpContext. Current;
}
Ctx is (the packet of HttpContext and all the data worth in the message, that is, the data transmitted by the client.