zoukankan      html  css  js  c++  java
  • C#一般处理程序中使用Session

    <%@ 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有只读的权限,也是空接口,无需实现任何方法。

  • 相关阅读:
    Form 中调用指定请求并给定默认参数
    OAF 汇总行的做法
    EBS 开发常用SQL
    EBS 中常用的配置文件及说明
    OAF 常见概念介绍
    OAF 多语言的实现
    OAF 个性化基础
    OAF 开发前置配置
    条款20 STL函数对象
    条款19 command 模式与好莱坞法则
  • 原文地址:https://www.cnblogs.com/haorensw/p/2509020.html
Copyright © 2011-2022 走看看