This is a er interface only, you don't need to implement anything

解决方案 »

  1.   

    what kind of component are you creating? you only need to implement IRequiresSessionState if you are creating custom handlersin other places, you don't need to implement it all, just use System.Web.HttpContext.Current.Session
      

  2.   

    举个例子说吧,我自定义一个类a,其中有一个方法b,是把一个字符串变量保存到一个session中,我用下面的代码,但总出错,请指点下:public class sessionTest : IRequiresSessionState
    {
    public HttpSessionState k;
    public static HttpSessionState sTest()
    {
    k.Add("a","ssssssssssssssss");
    return k;
    }
    }
      

  3.   

    it is meaningful only when you want to dopublic class NewHandler : IHttpHandler, IRequiresSessionState
    in your case, don't implement it, and just use System.Web.HttpContext.Current.Session directly
      

  4.   

    public class sessionTest
    {
    public static void sTest()
    {
    System.Web.HttpContext.Current.Session["a"]="ssssssssssssssss";
    }
    }
      

  5.   

    晕,你不就是为了在你单独的类里使用SESSION嘛,直接继承System.Web.UI.Page即可
      

  6.   

    非常感谢两位。不过我都糊涂了,我看资料说要在编译成DLL的类中直接使用response必须实现IHttpHandler接口,要使用session则必须实现IRequiresSessionState 接口,怎么现在可以直接用?谢谢解答
      

  7.   

    我上面已经说明白了,只有你自己写HttpHandler,又想使用Session时,你才需要实现IRequiresSessionState,否则,在普通的类里,用System.Web.HttpContext.Current.Session 就行了
      

  8.   

    我上面已经说明白了,只有你自己写HttpHandler,又想使用Session时,你才需要实现IRequiresSessionState,否则,在普通的类里,用System.Web.HttpContext.Current.Session 就行了