private static string GetActionRoute(HttpControllerContext controllerContext)
{
try
{
var routeName = string.Empty;
foreach (var r in controllerContext.RouteData.Route.DataTokens
.Where(r => r.Key == "actions")
.Where(r => r.Value != null || r.GetType() == typeof (HttpActionDescriptor[])))
{
routeName = ((HttpActionDescriptor[])r.Value)[0].ActionName;
break;
}
return routeName;
}
catch (Exception)
{
return "Cannot get action name";
}
}
}