oh yeah, session state...

2007-09-12 @ 00:43#

this week, a colleague has been working on integrating MS SQL Reporting tools into the web-hosting framework i built for our current round of projects. and it wasn't working.

turns out SQL Reporting tools requires ASP.NET Session State. and my framework doesn't use it (on purpose, of course). in fact, it's been so long since i wrote an HTTPHandler that supported session state, i forgot how to do it!

it's simple, really. you just need to mark your HTTPHandler with the IRequiresSessionState interface. like this:

using System.Web;
using System.Web.SessionState;

namespace E3.Galaxy.Web
{
    class GalaxyHandler : IHttpHandler,IRequiresSessionState
    {
        public void ProcessRequest(System.Web.HttpContext context)
        {
            // pass to our own handler
            RequestHandler rh = new RequestHandler(context);
        }

        public bool IsReusable
        {
            get { return false; }
        }
    }
}

now every request to our framework makes sure that there is a session associated with the request and marks the request with a cookie. and that's a good thing, right [sigh]?

code