From 244dcff8da15c0384404e93b5c9ac4e24cdc95a0 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 29 Aug 2013 14:51:30 +1000 Subject: [PATCH] Fixes: U4-1339 SurfaceController returning PartialView - cannot use ModelState ? --- src/Umbraco.Web/Mvc/UmbracoPageResult.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Mvc/UmbracoPageResult.cs b/src/Umbraco.Web/Mvc/UmbracoPageResult.cs index db0f352645..fa009a9c46 100644 --- a/src/Umbraco.Web/Mvc/UmbracoPageResult.cs +++ b/src/Umbraco.Web/Mvc/UmbracoPageResult.cs @@ -34,8 +34,13 @@ namespace Umbraco.Web.Mvc //ensure TempData and ViewData is copied across foreach (var d in context.Controller.ViewData) routeDef.Controller.ViewData[d.Key] = d.Value; - routeDef.Controller.TempData = context.Controller.TempData; + //We cannot simply merge the temp data because during controller execution it will attempt to 'load' temp data + // but since it has not been saved, there will be nothing to load and it will revert to nothing, so the trick is + // to Save the state of the temp data first then it will automatically be picked up. + // http://issues.umbraco.org/issue/U4-1339 + context.Controller.TempData.Save(context, ((Controller)context.Controller).TempDataProvider); + using (DisposableTimer.TraceDuration("Executing Umbraco RouteDefinition controller", "Finished")) { try