Session Key gets null while Session object is alive RRS feed

  • Question

  • User-863157348 posted

    I have a Authorizeclient.aspx.cs page where I set my session value.Authorizeclient.aspx is a blank page. 

    HttpContext.Current.Session["nodeID"]="0". This session value changes from 0 or non zero which depends on the value returned by Database. If no value is returned I assign HttpContext.Current.Session["nodeID"]="0" as the default state else I assign HttpContext.Current.Session["nodeID"]=resolve(nodeID).ToString()

    Till this part it works fine as expected. However, I have a requirement that I need to read the nodeID from Session in other application on the same server. I mean this application too is part of the root project where I initially created the Session and set it.

    The strange thing is the Session["nodeID"] in application gets null "SOMETIMES" Not always. I am trying to read the Session in Page_Load. Sometimes it works fine and sometimes it gets null. Moreover the session object do not die and I can see other keys like Session["Themes"] etc there.

    I am not sure why this is happening. The session is in InProc mode and have 20 minutes timeout time. Please help me in this regard 


    Thursday, January 27, 2011 4:09 PM

All replies

  • User-2135385890 posted

    Each application has his own session. A work around is to use SQLServer instead of InProc:


    Thursday, January 27, 2011 8:06 PM
  • User1288683547 posted

    might be you are checking before assign values in the  Session["nodeID"]


    Both application running in same root path in the IIS?

    Friday, January 28, 2011 2:59 AM
  • User1791120482 posted

    Here is simple solution if all applications are hosted on same server in same virtual folder


     Another solution which tweaks the default Session creation behavior


    Friday, January 28, 2011 3:07 AM
  • User-863157348 posted

     I cannot use SQL Session as that requires huge changes. The strange thing is the session does get set :

    Authorizclient.aspx(this is called thru Ajax on login):

    HttpContext.Current.Session["ACONodeId"] = nodeOptions.ACONodeOptionsNodeId;(This do some DB calls)


    Then in some app:

    String ACONodeId =

    string.IsNullOrEmpty(ViewState["ACONodeId"] as string


    if (!string.IsNullOrEmpty(ACONodeId) && ACONodeId != "-1")


    nodelogger.Log("1015", new Dictionary<string, string>() { { "APPLICATION", "Media Deposit" }, { "FUNCTIONNAME", "Page_Load" }, { "EXCEPTION", "NodeID has been assigned to this client" } });



    This works fine but sometimes in the middle of applications the

    Session["ACONodeId"] gets null. This happens randomly and has no pattern.


    Pls suggest me if I am doing something wrong

    Saturday, January 29, 2011 8:01 PM
  • User-863157348 posted

    MOREOVER PLEASE NOT THAT BOTH THE APPLICATIONS (AuthorizeClient.aspx) and the app where I read Session are part of the same application. SO ITS NOT ABOUT SHARING THE SESSION AMONG DIFFERENT APPLICATION.

    Only My Session key gets null  after some time. Even though no where its being set to null


    Saturday, January 29, 2011 8:11 PM
  • User1867929564 posted

    Can you explain the scenario ?
    I login into root project then from here i can move to other application,web config is same for all.
    Other session which are working ok do not come from database.right ?
    I think if database connection even break for a milisec then this probem occurs.

    Wednesday, February 2, 2011 5:44 AM