Session state not working in ashx file on server RRS feed

  • Question

  • User-1335903275 posted

    I'm having a strange session issue, where my handler is not reading the session values.  This ONLY occurs on our server.  When I run locally, it works fine.  I'm also already calling IRequiresSessionState, so that shouldn't be an issue either.  

    When I run Trace.axd, I'm able to see the session state is still working up until I call my ashx file.  Inside this file however, the session is lost, according to my trace.  

    Here's my javascript code I use to call my handler:


            type: 'POST',
            url: '/MySite/Handlers/MyHandler.ashx',
            data: { type: "Type_1",
                    ID: $("#ID").val()
            async: false,
            dataType: "json"

    And here's my handler:

    using System.Web;
    using System.Web.SessionState;
    namespace MySite.Web.Handlers
        /// <summary>
        /// Summary description for handler
        /// </summary>
        public class MyHandler : IHttpHandler, IRequiresSessionState
            public void ProcessRequest(HttpContext context)
                if (HttpContext.Current.Session["CurrentUser"] == null) return;
                //do something here
            public bool IsReusable
                    return false;

    So, like I said, up until my handler, my "CurrentUser" session variable has a value.  But once I reach the handler, the value disapears.  Any idea what I'm doing wrong?


    Tuesday, May 28, 2013 3:06 PM

All replies

  • User-851967432 posted

    Are your sessions handled inproc?

    Tuesday, May 28, 2013 3:49 PM