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

Source: Internet
Author: User

This article describes the use of the session in the General processing program in ASP.

<%@ WebHandler language="C #"class="changepwd"%>usingSystem;usingsystem.web;usingSystem.Web.SessionState; Public classChangepwd:ihttphandler, ireadonlysessionstate { Public voidProcessRequest (HttpContext context) {context. Response.ContentType="Text/plain"; Operuser ou=NewOperuser (); if(OU. Changewspassword (context. session["Ws_user"]. ToString (), context. request.querystring["pwd"]. ToString ())) {context. Response.Write ("true"); }         Else{context. Response.Write ("flase"); }     }      Public BOOLisreusable {Get {             return false; }     } }

plus the using System.Web.SessionState; ireadonlysessionstate

If your handler accesses a session-state value, it must implement the 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 of the methods.
With this, there is another interface: The Ireadonlysessionstate interface, which is used to indicate HTTP handlers, read-only permissions to the session, and an empty interface, without implementing any methods.

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

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.