在HttpHandlers (ASHX files)中使用Session
当你希望从ashx或HttpHandler里访问你的Session时,你必须实现IReadOnlySessionState接口.
代码:
using System;
using System.Web;
using System.Web.SessionState;
public class DownloadHandler : IHttpHandler, IReadOnlySessionState
{
public bool IsReusable { get { return true; } }
public void ProcessRequest(HttpContext ctx)
{
ctx.Response.Write(ctx.Session["fred"]);
}
}
using System.Web;
using System.Web.SessionState;
public class DownloadHandler : IHttpHandler, IReadOnlySessionState
{
public bool IsReusable { get { return true; } }
public void ProcessRequest(HttpContext ctx)
{
ctx.Response.Write(ctx.Session["fred"]);
}
}
posted on 2005-07-19 16:57 Goodspeed 阅读(1933) 评论(1) 编辑 收藏 举报