private string getDefaultControllerActionUrl(ActionExecutingContext filterContext) { var defaultRoute = filterContext.RouteData.Routers.OfType <Route>().FirstOrDefault(); if (defaultRoute == null) { throw new InvalidOperationException("The default route of this controller not found."); } var defaultAction = defaultRoute.Defaults["action"] as string; if (defaultAction == null) { throw new InvalidOperationException("The default action of this controller not found."); } if (RemoveAllDefaultRouteValues) { return(new UrlHelper(filterContext).ActionWithoutRouteValues(defaultAction)); } if (RemoveRouteValues == null || !RemoveRouteValues.Any()) { return(new UrlHelper(filterContext).Action(defaultAction)); } return(new UrlHelper(filterContext).ActionWithoutRouteValues(defaultAction, RemoveRouteValues)); }
private string getDefaultControllerActionUrl(ActionExecutingContext filterContext) { var defaultAction = getDefaultAction(filterContext); var urlHelper = getUrlHelper(filterContext); if (RemoveAllDefaultRouteValues) { return(urlHelper.ActionWithoutRouteValues(defaultAction)); } if (RemoveRouteValues == null || !RemoveRouteValues.Any()) { return(urlHelper.Action(defaultAction)); } return(urlHelper.ActionWithoutRouteValues(defaultAction, RemoveRouteValues)); }
private string getDefaultControllerActionUrl(ResultExecutingContext filterContext) { var defaultAction = string.Empty; var urlHelper = getUrlHelper(filterContext); if (RemoveAllDefaultRouteValues) { return(urlHelper.ActionWithoutRouteValues(defaultAction)); } if (RemoveRouteValues?.Any() != true) { return(urlHelper.Action(defaultAction)); } return(urlHelper.ActionWithoutRouteValues(defaultAction, RemoveRouteValues)); }
private string getDefaultControllerActionUrl(ActionExecutingContext filterContext) { var defaultAction = UseCurrentRouteUrl ? ((Route)filterContext.RequestContext.RouteData.Route).Defaults["action"] as string : ((Route)RouteTable.Routes["Default"]).Defaults["action"] as string; if (RemoveAllDefaultRouteValues) { return(new UrlHelper(filterContext.RequestContext).ActionWithoutRouteValues(defaultAction)); } if (RemoveRouteValues == null || !RemoveRouteValues.Any()) { return(new UrlHelper(filterContext.RequestContext).Action(defaultAction)); } return(new UrlHelper(filterContext.RequestContext).ActionWithoutRouteValues(defaultAction, RemoveRouteValues)); }