Merge pull request #168 from stevetemple/6.1.6-multiple-action-route-issue
Fix error when multiple routes have the same controller
This commit is contained in:
@@ -217,14 +217,26 @@ namespace Umbraco.Web.Mvc
|
||||
Route surfaceRoute;
|
||||
if (postedInfo.Area.IsNullOrWhiteSpace())
|
||||
{
|
||||
//find the controller in the route table without an area
|
||||
surfaceRoute = RouteTable.Routes.OfType<Route>()
|
||||
.SingleOrDefault(x => x.Defaults != null &&
|
||||
x.Defaults.ContainsKey("controller") &&
|
||||
x.Defaults["controller"].ToString() == postedInfo.ControllerName &&
|
||||
!x.DataTokens.ContainsKey("area"));
|
||||
//find the controller in the route table without an area
|
||||
var surfaceRoutes = RouteTable.Routes.OfType<Route>()
|
||||
.Where(x => x.Defaults != null &&
|
||||
x.Defaults.ContainsKey("controller") &&
|
||||
String.Equals(x.Defaults["controller"].ToString(), postedInfo.ControllerName, StringComparison.InvariantCultureIgnoreCase) &&
|
||||
!x.DataTokens.ContainsKey("area")).ToList();
|
||||
|
||||
// If more than one route is found, find one with a matching action
|
||||
if (surfaceRoutes.Count() > 1)
|
||||
{
|
||||
surfaceRoute = surfaceRoutes.SingleOrDefault(x =>
|
||||
String.Equals(x.Defaults["action"].ToString(), postedInfo.ActionName, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
else
|
||||
{
|
||||
surfaceRoute = surfaceRoutes.SingleOrDefault();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
//find the controller in the route table with the specified area
|
||||
surfaceRoute = RouteTable.Routes.OfType<Route>()
|
||||
|
||||
Reference in New Issue
Block a user