Scott Hanselman

Getting Session State in HttpHandlers (ASHX files)

November 12, '03 Comments [2] Posted in ASP.NET | HttpHandler
Sponsored By

A reminder to myself and others, when you want to get access to your Session State from an ASHX or HttpHandler, you need to implement IReadOnlySessionState:

<% @ webhandler language="C#" class="DownloadHandler" %>

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)

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Wednesday, 12 November 2003 22:21:42 UTC
Or IRequiresSessionState if you need read/write access.
Friday, 30 September 2005 09:34:58 UTC
Thanks a lot for this tips :)
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.