title: How to access HttpContext outside of controllers in ASP.NET MVC?
body: <p>Specifically, Session variables. I have an .ashx in my ASP.NET MVC project that is pulling some image data to display to a user, and I need to be able to access an object that I've stored in the session. From controllers I can pull the object fine, but in my ashx page, the context.Session is null. Any thoughts? Thanks!</p>
  
  <p>Here is an example of what I'm trying to do...  context.Session is always returning null.</p>
  
  <pre><code>  private byte[] getIconData(string icon)
      {
          //returns the icon file
          HttpContext context = HttpContext.Current;
  
          byte[] buffer = null;
  
          //get icon data
          if ( context.Session["tokens"] != null)
          {
              //do some stuff to get icon data
          }
      }
  </code></pre>