title: Persisting model data on form post when redisplaying the view for an invalid ModelState
body: <p>Simplified example:</p>
  
  <pre><code>[HttpGet]
  public ActionResult Report(DateTime? date)
  {
      if (!date.HasValue)
      {
          date = DateTime.Now;
      }
  
      // Clear the ModelState so that the date is displayed in the correct format as specified by the DisplayFormat attribute on the model
      ModelState.Clear();
  
      // Expensive call to database to retrieve the report data
      ReportModel model = DataAdapter.Convert(this.reportService.GetReport((DateTime)date));
  
      // Store in TempData in case validation fails on HttpPost
      TempData["ReportModel"] = model;
  
      return View(model);
  }
  
  [HttpPost]
  public ActionResult Report(ReportModel model)
  {
      if (ModelState.IsValid)
      {
          return RedirectToAction("Report", new { date = model.Date });
      }
      else
      {
          // Load the report from TempData, and restore again in case of another validation failure
          model = TempData["ReportModel"] as ReportModel;
          TempData["ReportModel"] = model;
  
          // Redisplay the view, the user inputted value for date will be loaded from ModelState
          return View(model);
      }
  }
  </code></pre>
  
  <p>My question is, am I going about this the right way by storing the report data in TempData?  The code seems a little strange especially reading from and then writing back to TempData in the HttpPost action method to ensure it persists the next request. </p>
  
  <p>Other options I can think of are:</p>
  
  <p>(1) Make another call to the service layer from the HttpPost action (I'd rather not make another database call because of a validation failure just to redisplay the form as it seems inefficient).  I guess I could implement caching at the service layer to avoid the database round trip...</p>
  
  <p>(2) Use hidden inputs in the form (yuk!).</p>
  
  <p>(3) Store the most recently viewed report in session permanently.</p>
  
  <p>How is everyone else doing this sort of thing?  What's the recommended practice?</p>