Asp. A brief introduction to using the session in a generic handler in net

Source: Internet
Author: User
<%@ WebHandler language= "C #" class= "Changepwd"%> using System; using system.web; Using System.Web.SessionState;         public class Changepwd:ihttphandler, ireadonlysessionstate {public void ProcessRequest (HttpContext context) { Context.         Response.ContentType = "Text/plain";         Operuser ou = new Operuser (); if (OU. Changewspassword (context. session["Ws_user"]. ToString (), context. request.querystring["PWD"]. ToString ())) {context.         Response.Write ("true"); } else {context.         Response.Write ("Flase");         }} public bool IsReusable {get {return false; }     } }

Plus using System.Web.SessionState; ireadonlysessionstate

If your handler accesses session-state values, it must implement IRequiresSessionState Interface (a markup interface that does not contain any methods).


Import using System.Web.SessionState;
Sure enough, as long as you add a irequiressessionstate tag interface to your custom class, you don't need to implement any methods.
With this, there is another interface: The Ireadonlysessionstate interface, which indicates an HTTP handler, a read-only permission to the session, and an empty interface, without implementing any method.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.