title: Losing session data stored in one PartialViewResult when trying to retrieve it in another PartialViewResult
body: <p>I have a scenario where in I am using the Session to store an object in one controller action and trying to retrieve it another controller action. Both the actions are triggered from the same view and reside on the same controller. Unfortunately, I am not able to retrieve the session variable in the second controller. The session Id remains the same and I am ensuring that the object was written into the session in the first action. The session data, however, disappears when the view is returned in the first action.</p>
  
  <p>Here is my Controller code flow -</p>
  
  <pre><code>public PartialviewResult DoSearch(string paramCustId)
  {
  //invoking a method to perform a search task. I am also passing the controller session as a parameter
  //this function is called in a separate thread and the main thread does not wait for it to complete before returning the view
  multiSearch(paramCustId, Session);
  }
  return PartialView("_partialView1");
  
  public void multiSearch(string searchParam, HttpSessionStateBase controllerSession)
  {
  //code to retrieve response from backend into the variable tempSearchSet
  controllerSession["searchResult"] = tempSearchSet;
  //verified that tempSearchSet is stored in Session under the key "searchResult" and Session.Count is 1.
  }
  
  
  //Another controller action that is triggered from the same view after a certain delay to fetch the data in session
  public PartialViewResult PollSearchResults()
  {
  var tempSearchResult = Session["searchResult"] as List&lt;SearchResultSet&gt;;
  //This is where i do not see data in the session. I have verified that the multiSearch method is complete and has updated the data in the session.
  //here Session.SessionID is the same as above, but Session.Count is 0
  }
  </code></pre>
  
  <p>Is there a different way to handle Session in mvc or am i missing something elementary here? Also, is there a better approach to manage this caching scenario?</p>