Fixes: #U4-1727

This commit is contained in:
Shannon Deminick
2013-02-19 06:11:17 +06:00
parent d01a39e0c6
commit 7d1e9cfd72
2 changed files with 8 additions and 8 deletions

View File

@@ -181,12 +181,11 @@ namespace Umbraco.Web.Mvc
//set the standard route values/tokens
requestContext.RouteData.Values["controller"] = postedInfo.ControllerName;
requestContext.RouteData.Values["action"] = postedInfo.ActionName;
requestContext.RouteData.DataTokens["area"] = postedInfo.Area;
IHttpHandler handler = new MvcHandler(requestContext);
//ensure the controllerType is set if found, meaning it is a plugin, not locally declared
if (postedInfo.Area != standardArea)
if (!postedInfo.Area.InvariantEquals(standardArea))
{
//requestContext.RouteData.Values["controllerType"] = postedInfo.ControllerType;
//find the other data tokens for this route and merge... things like Namespace will be included here
@@ -195,12 +194,15 @@ namespace Umbraco.Web.Mvc
var surfaceRoute = RouteTable.Routes.OfType<Route>()
.SingleOrDefault(x => x.Defaults != null &&
x.Defaults.ContainsKey("controller") &&
x.Defaults["controller"].ToString() == postedInfo.ControllerName &&
x.Defaults["controller"].ToString().InvariantEquals(postedInfo.ControllerName) &&
x.DataTokens.ContainsKey("area") &&
x.DataTokens["area"].ToString() == postedInfo.Area);
x.DataTokens["area"].ToString().InvariantEquals(postedInfo.Area));
if (surfaceRoute == null)
throw new InvalidOperationException("Could not find a Surface controller route in the RouteTable for controller name " + postedInfo.ControllerName + " and within the area of " + postedInfo.Area);
//set the 'Namespaces' token so the controller factory knows where to look to construct it
requestContext.RouteData.DataTokens["area"] = surfaceRoute.DataTokens["area"];
//set the 'Namespaces' token so the controller factory knows where to look to construct it
if (surfaceRoute.DataTokens.ContainsKey("Namespaces"))
{
requestContext.RouteData.DataTokens["Namespaces"] = surfaceRoute.DataTokens["Namespaces"];
@@ -210,8 +212,6 @@ namespace Umbraco.Web.Mvc
}
//store the original URL this came in on
requestContext.RouteData.DataTokens["umbraco-item-url"] = requestContext.HttpContext.Request.Url.AbsolutePath;
//store the original route definition
requestContext.RouteData.DataTokens["umbraco-route-def"] = routeDefinition;

View File

@@ -127,7 +127,7 @@ namespace Umbraco.Web
//Create the REST/web/script service routes
var webServiceRoutes = RouteTable.Routes.MapRoute(
"Umbraco_web_services",
"Umbraco/RestServices/{controller}/{action}/{id}",
umbracoPath + "/RestServices/{controller}/{action}/{id}",
new {controller = "SaveFileController", action = "Index", id = UrlParameter.Optional},
//VERY IMPORTANT! for this route, only match controllers in this namespace!
new string[] { "Umbraco.Web.WebServices" }