<%@ 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; and IReadOnlySessionState
If your handler will access session state values, it must implement the IRequiresSessionState interface (a tagged interface that does not contain any methods).
Import using System.Web.SessionState;
Sure enough, just add an IRequiresSessionState mark interface to the custom class, and there is no need to implement any methods.
At the same time, there is another interface: the IReadOnlySessionState interface, which is used to instruct the Http handler to have read-only permissions on the Session. It is also an empty interface and does not need to implement any methods.
For more related articles on the simple introduction of using session in general processing programs in ASP.NET, please pay attention to the PHP Chinese website!