zoukankan      html  css  js  c++  java
  • C#使用一般处理程序(ashx)中session

    .ashx中引用 session必须 using System.Web.SessionState ,继承IReadOnlySessionState/IRequiresSessionState

    IReadOnlySessionState,为只读的session 不可以修改

    IRequiresSessionState ,可以修改。

    using System;
    using System.Web;
    using System.Text;
    using System.Web.SessionState; //这是在.ashx 中引用session 的必备条件之一

     public class GetCheckData : IHttpHandler,IRequiresSessionState //继承IRequiresSessionState
     {

       public void ProcessRequest(HttpContext context)
        {        
           context.Response.ContentType = "text/plain";

           string ds="1234";

           context.Session["ds"] = ds;//这只是简单的使用方法,可以根据自己的要求改

           HttpContext.Current.Session["ds"]=ds;//第二种方法

           context.Response.Write(ds);

        }   

    }

  • 相关阅读:
    绑定姿势
    Mesh.CombineMeshes
    Mono vs IL2CPP
    lua keynote2
    lua keynote
    游戏编程模式KeyNote
    架构、性能和游戏
    Canvas
    AssetBundle Manager
    Loading AssetBundle Manifests
  • 原文地址:https://www.cnblogs.com/gca123/p/6567371.html
Copyright © 2011-2022 走看看