现在的位置: 首页 > 综合 > 正文

在.ashx文件下使用session[转]

2012年12月08日 ⁄ 综合 ⁄ 共 344字 ⁄ 字号 评论关闭

在一般处理程序中使用session时必须继承一下   System.Web.SessionState.IReadOnlySessionState   的接口,否则为会出

"未将对象引用设置到对象的实例。 "

首先需要引用 using System.Web.SessionState;

并实现类的IReadOnlySessionState接口

public class CheckMemberLogin : IHttpHandler,IReadOnlySessionState{

public void ProcessRequest (HttpContext context) {

 if(context.Session["membername"]==null)

{

context.Response.Write("会员已登录");

}

}

}

抱歉!评论已关闭.