C# 如何从通用处理程序访问会话

C# 如何从通用处理程序访问会话,c#,asp.net,C#,Asp.net,在ashx中: 我将数据放入实体列表中,并将其分配给会话 context.Session["objList"] = myEntityCollection; 我想通过回应获得这次会议;在代码隐藏中。 它是如何实现的 context.Response.ContentType = ??? ..... context.Response.Write(context.Session["objList"]); 将对象序列化为JSON,返回带有响应的序列化字符串,并使用application/JSONCon

在ashx中: 我将数据放入实体列表中,并将其分配给会话

context.Session["objList"] = myEntityCollection;
我想通过回应获得这次会议;在代码隐藏中。 它是如何实现的

context.Response.ContentType = ???
.....
context.Response.Write(context.Session["objList"]);

将对象序列化为JSON,返回带有响应的序列化字符串,并使用
application/JSON
ContentType

Hi,如果我理解正确的话。要访问ashx文件中的会话数据,需要实现该接口


谢谢你的回复。但我已经在用了。问题是,我没有获取对象,而是在代码隐藏中获取对象的名称。
public class ExampleHttpHandler : IHttpHandler, IRequiresSessionState
{
    public bool IsReusable
    {
        get
        {
            return false;
        }
    } 

    public void ProcessRequest(HttpContext context)
    {    
        context.Session["test"] = "test";
        context.Response.Write(context.Session["test"]);
    }
}