Reputation: 10123
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?
Upvotes: 1
Views: 1766
Reputation: 160892
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.
Upvotes: 3