ASP.NET一般处理程序访问Session问题

我们在使用一般处理程序的时候,访问Session会出现如下错误:

解决方案如下:

//引用命名空间
using System.Web.SessionState;

//继承IRequiresSessionState接口,拥有Session的读写权限
//继承IReadOnlySessionState接口,拥有Session的只读权限
public class Handler1 : IHttpHandler,IRequiresSessionState
    {

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

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }

 

posted @ 2014-04-19 12:18  雲霏霏  阅读(1256)  评论(0编辑  收藏  举报