Goodspeed

导航

统计

公告

2005年7月19日 #

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

}


posted @ 2005-07-19 16:57 Goodspeed 阅读(1739) 评论(1) 编辑