title: How to keep using ModelState with RedirectToAction in ASP.NET MVC 6?
body: <p>I have a method to remove the object. Removal does not own view, and is a "Delete" button in the "EditReport". Upon successful removal of a redirect on "Report".</p>
  
  <pre><code>[HttpPost]
  [Route("{reportId:int}")]
  [ValidateAntiForgeryToken]
  public IActionResult DeleteReport(int reportId)
  {
      var success = _reportService.DeleteReportControl(reportId);
      if (success == false)
      {
          ModelState.AddModelError("Error", "Messages");
          return RedirectToAction("EditReport");
      }
      ModelState.AddModelError("OK", "Messages");
      return RedirectToAction("Report");
  }
  </code></pre>
  
  <p>In ASP.NET MVC 5 I use the following attributes to save ModelState between methods. I took from here: <a href="https://stackoverflow.com/a/12024227/3878213">https://stackoverflow.com/a/12024227/3878213</a></p>
  
  <pre><code>public class SetTempDataModelStateAttribute : ActionFilterAttribute
  {
      public override void OnActionExecuted(ActionExecutedContext filterContext)
      {
          base.OnActionExecuted(filterContext);         
          filterContext.Controller.TempData["ModelState"] = 
             filterContext.Controller.ViewData.ModelState;
      }
  }
  
  public class RestoreModelStateFromTempDataAttribute : ActionFilterAttribute
  {
      public override void OnActionExecuting(ActionExecutingContext filterContext)
      {
          base.OnActionExecuting(filterContext);
          if (filterContext.Controller.TempData.ContainsKey("ModelState"))
          {
              filterContext.Controller.ViewData.ModelState.Merge(
                  (ModelStateDictionary)filterContext.Controller.TempData["ModelState"]);
          }
      }
  }
  </code></pre>
  
  <p>But in ASP.NET MVC 6 RC 1 (ASP.NET Core 1.0), this code does not work. </p>
  
  <p>Error in filterContext.Controller does not contain definitions for TempData and ViewData.</p>