title: ModelState, TempData, ViewModel issue - new viewmodel value automatically gets overridden
body: <p>This problem is best explained with code:</p>
  
  <pre><code>    public async Task&lt;ActionResult&gt; Index()
      {
  
  
          if (TempData.ContainsKey("ModelState"))
          {
              ModelState.Merge((ModelStateDictionary)TempData["ModelState"]);
  
  
              var viewModelA= new ViewModelA
              {
                   FirstName = "John"
              }
              return View(viewModelA);
          }
       }
  
  
  
      [HttpPost]
      public async Task&lt;ActionResult&gt; IndexPostActionMethod(ViewModelB model)
      {
          if (ModelState.IsValid)
          {
  
              var result = await DoSomeStuff();
              if (result.Succeeded)
              {
                  DoSomeOtherStuff();
              }
              else
              {
                  AddErrors(result);
              }
          }
  
  
  
  
  
          TempData["ModelState"] = ModelState;
          return RedirectToAction("Index");
  
      }
  </code></pre>
  
  <p>The problem here is that when I post to <code>IndexPostActionMethod</code> and <code>DoSomeStuff()</code> returns <code>false</code> for some reason, the form/page is rediplayed by redirecting to <code>Index</code> and saving the <code>ModelState</code> in <code>TempData</code> during that redirect and then once the form/page is redisplayed, the value from <code>ModelState</code> (or where does it get the value from?) gets set as the value for a <code>@Html.TextBoxFor(m =&gt; m.FirstName)</code> and not the value that I set here: <code>var viewModelA = new ViewModelA { FirstName = "John"}</code>. Why can't I override the value and where does it get it from? It's like the framework is automatically updating <code>viewModelA</code> with whatever is in the <code>ModelStatDictionary</code> eventhough I create a new <code>ViewModelA</code> with a new value.</p>