开发者

Clear session in logout.ashx

I have an ashx handler and want to clear the session on request. I am getting object not set to instance of object on the Session.Abondon() line. I am trying to logout a user.

 public void ProcessRequest开发者_运维知识库 (HttpContext context) {
    //context.Response.ContentType = "text/plain";
    //context.Response.Write("Hello World");
    FormsAuthentication.SignOut();
    context.Session.Abandon();
    context.Response.Redirect("/login.aspx");        
 } 

Am I doing something wrong?


Did you forget to implement IReadOnlySessionState or IRequiresSessionState in your handler by chance? If so you would not have access to the Session and get this error. These are marker interfaces whose sole purpose it is to give you access to the Session.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜