diff --git a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs
index 43d7416a23..da6d761745 100644
--- a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs
+++ b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs
@@ -173,8 +173,7 @@ namespace Umbraco.Web.Mvc
///
///
///
- /// The original route definition that would normally be used to route if it were not a POST
- private IHttpHandler HandlePostedValues(RequestContext requestContext, PostedDataProxyInfo postedInfo, RouteDefinition routeDefinition)
+ private IHttpHandler HandlePostedValues(RequestContext requestContext, PostedDataProxyInfo postedInfo)
{
//set the standard route values/tokens
requestContext.RouteData.Values["controller"] = postedInfo.ControllerName;
@@ -210,9 +209,6 @@ namespace Umbraco.Web.Mvc
}
- //store the original route definition
- requestContext.RouteData.DataTokens["umbraco-route-def"] = routeDefinition;
-
return handler;
}
@@ -277,7 +273,9 @@ namespace Umbraco.Web.Mvc
}
}
-
+
+ //store the route definition
+ requestContext.RouteData.DataTokens["umbraco-route-def"] = def;
return def;
}
@@ -290,12 +288,12 @@ namespace Umbraco.Web.Mvc
internal IHttpHandler GetHandlerForRoute(RequestContext requestContext, PublishedContentRequest publishedContentRequest)
{
var routeDef = GetUmbracoRouteDefinition(requestContext, publishedContentRequest);
-
+
//Need to check for a special case if there is form data being posted back to an Umbraco URL
var postedInfo = GetPostedFormInfo(requestContext);
if (postedInfo != null)
{
- return HandlePostedValues(requestContext, postedInfo, routeDef);
+ return HandlePostedValues(requestContext, postedInfo);
}
//here we need to check if there is no hijacked route and no template assigned, if this is the case
diff --git a/src/Umbraco.Web/Mvc/SurfaceController.cs b/src/Umbraco.Web/Mvc/SurfaceController.cs
index c114b286dc..463162694f 100644
--- a/src/Umbraco.Web/Mvc/SurfaceController.cs
+++ b/src/Umbraco.Web/Mvc/SurfaceController.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Web.Mvc;
+using System.Web.Routing;
using Umbraco.Core.Models;
using Umbraco.Core;
@@ -76,10 +77,16 @@ namespace Umbraco.Web.Mvc
{
get
{
- if (!ControllerContext.RouteData.DataTokens.ContainsKey("umbraco-route-def"))
- throw new InvalidOperationException("Can only use " + typeof(UmbracoPageResult).Name + " in the context of an Http POST when using the BeginUmbracoForm helper");
+ var routeData = ControllerContext.IsChildAction
+ ? ControllerContext.ParentActionViewContext.RouteData
+ : ControllerContext.RouteData;
- var routeDef = (RouteDefinition)ControllerContext.RouteData.DataTokens["umbraco-route-def"];
+ if (!routeData.DataTokens.ContainsKey("umbraco-route-def"))
+ {
+ throw new InvalidOperationException("Cannot find the Umbraco route definition in the route values, the request must be made in the context of an Umbraco request");
+ }
+
+ var routeDef = (RouteDefinition)routeData.DataTokens["umbraco-route-def"];
return routeDef.PublishedContentRequest.PublishedContent;
}
}