title: Session not persisting between requests
body: <p>Creating this as I looked at <a href="https://stackoverflow.com/questions/18337256/mvc4-session-not-persisted-between-requests">MVC4 Session not persisted between requests</a> and various others but none of them helped to solve my issue.</p>
  <p>I have the following two action methods on my MVC controller:</p>
  <pre><code>    public ActionResult Capture(string testValue)
      {
          Session[&quot;Test&quot;] = testValue;
          ViewBag.Test = Session[&quot;Test&quot;]; // This works and correctly sets the value
          return View();
      }
  
      [HttpPost]
      public ActionResult Capture(SomeViewModel viewModel)
      {
          ViewBag.Test = Session[&quot;Test&quot;]; // At this point the value in the session is inexplicably null, and thus so is the item in the ViewBag
  
          return View(viewModel);
      }
  </code></pre>
  <p>When I try and use <code>ViewBag.Test</code> in my view</p>
  <ul>
  <li>On the initial Get, it works</li>
  <li>On the Post, it is null.</li>
  </ul>
  <p>The same behaviour if I set a breakpoint in the code, the session object is set and has the right value in the initial &quot;Get&quot; but is null in the Post after.</p>
  <p>What is happening to my session, why is the value not being persisted between requests?</p>
  <p>I have established that the session is being created on every request but cannot see why.</p>