I have run into this one several times now, and want to make a note of it.
I sometimes create .NET Http Handlers that need to access session variables. HttpHandlers are .NET class that implement the IHttpHandler interface. By default these classes will throw an error if you try to use the Session object at all.
You can easily enable Session access by implementing the IRequiresSessionState interface.
public class VehicleIdCard : IHttpHandler, IRequiresSessionState {
public void ProcessRequest (HttpContext context) {
string myVar = context.Session["MySessVar"];
}
public bool IsReusable {
get {
return false;
}
}
}