using System; using System.Web; using System.Web.SessionState; public class ChangePwd : IHttpHandler, IReadOnlySessionState { public void ProcessR">

ASP.NET中在一般处理程序中使用session的简单介绍

来源:这里教程网 时间:2026-02-21 13:08:34 作者:

<%@ 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; 
        } 
    } 
}

加上 using system.web.sessionstate;和 ireadonlysessionstate

如果您的处理程序将访问会话状态值,它必须实现 irequiressessionstate 接口(不包含任何方法的标记接口)。 

 
导入using system.web.sessionstate; 
果然,只要对自定义类加上一个irequiressessionstate标记接口就可以了,也不需要实现任何的方法。 
与此,同时还有另一个接口:ireadonlysessionstate接口,用于指示http处理程序,对session有只读的权限,也是空接口,无需实现任何方法。

更多ASP.NET中在一般处理程序中使用session的简单介绍相关文章请关注PHP中文网!

相关推荐