C# 在logout.ashx中清除会话

C# 在logout.ashx中清除会话,c#,asp.net,session,authentication,C#,Asp.net,Session,Authentication,我有一个ashx处理程序,希望根据请求清除会话。在Session.Abondon()行中,我正在将对象未设置为对象的实例。我正在尝试注销一个用户 public void ProcessRequest (HttpContext context) { //context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); FormsAuthentication.SignO

我有一个ashx处理程序,希望根据请求清除会话。在Session.Abondon()行中,我正在将对象未设置为对象的实例。我正在尝试注销一个用户

 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");        
 } 

我做错了什么吗?

您是不是碰巧忘记了在处理程序中实现?如果是这样的话,您将无法访问会话并出现此错误。这些是标记接口,其唯一目的是让您能够访问会话。

就是这样。非常感谢。我会在15分钟内检查。