Skip to content

Commit

Permalink
Fix for #416, null reference exception in certain configurations caus…
Browse files Browse the repository at this point in the history
…ed by ControllerTypeResolver returning null.
  • Loading branch information
NightOwl888 committed Oct 27, 2015
1 parent a04df55 commit f9fc69f
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,14 @@ internal static void SetMvcCodeRoutingContext(this RouteData routeData, ISiteMap
return;

var controllerType = node.SiteMap.ResolveControllerType(node.Area, node.Controller);
var mvcCodeRoutingRouteContext = GetMvcCodeRoutingRouteContext(controllerType, node.Controller);
routeData.DataTokens["MvcCodeRouting.RouteContext"] = mvcCodeRoutingRouteContext;

// Fix for #416 - If Areas are misconfigured, controllerType may be null. Since MvcCodeRouting
// doesn't work in conjunction with Areas anyway, we are going to ignore this here.
if (controllerType != null)
{
var mvcCodeRoutingRouteContext = GetMvcCodeRoutingRouteContext(controllerType, node.Controller);
routeData.DataTokens["MvcCodeRouting.RouteContext"] = mvcCodeRoutingRouteContext;
}
}

private static string GetMvcCodeRoutingRouteContext(Type controllerType, string controllerName)
Expand Down

0 comments on commit f9fc69f

Please sign in to comment.