请问asp.net在一般处理页面如何使用session存值,这样存值对吗
context.Session["username"]=username;为什么不行呢?总是报错说未将对象引用到实例对象sessionasp.net对象实例

解决方案 »

  1.   

    ashx页面加上
    using System.Web.SessionState;
    然后在IHttpHandler后面加上", IReadOnlySessionState"(不包括引号)
      

  2.   

    上面那个是只读session的,你要写session就换成 IRequiresSessionState
      

  3.   

    refer:http://www.cnblogs.com/TivonStone/archive/2012/04/06/2434796.html
      

  4.   

    楼上回答了,ashx默认不支持session,必须加上两个session接口声明虽然这两个接口其实什么都没做
      

  5.   

    string username= context.Session["username"].ToString();
      

  6.   

    public class ImageHandler : IHttpHandler, System.Web.SessionState.IRequiresSessionStatecontext.Session["nixihuan"];
    Session是从其他页面传过来,ashx处理Session带来的数据,ashx如果要传出数据,就return something!
      

  7.   

    实现IRequiresSessionState接口,通过Http上下文,可以获取到Session