Пример #1
0
        public static string BuildUrlFromExpression <TController>(RequestContext context, RouteCollection routeCollection, Expression <Action <TController> > action) where TController : Controller
        {
            var             routeInfo = ExpressionHelper.GetRouteInfoFromExpression(routeCollection, action);
            VirtualPathData vpd       = routeCollection.GetVirtualPathForArea(context, routeInfo.Key, routeInfo.Value);

            return((vpd == null) ? null : vpd.VirtualPath);
        }
Пример #2
0
        public static RedirectToRouteResult RedirectToAction <TController>(this Controller controller, Expression <Action <TController> > action) where TController : Controller
        {
            if (controller == null)
            {
                throw new ArgumentNullException("controller");
            }

            var routeInfo = ExpressionHelper.GetRouteInfoFromExpression(RouteTable.Routes, action);

            return(new RedirectToRouteResult(routeInfo.Key, routeInfo.Value));
        }
Пример #3
0
        public static MvcHtmlString ActionLink <TController>(this HtmlHelper helper, Expression <Action <TController> > action, string linkText, object htmlAttributes) where TController : Controller
        {
            var routeInfo = ExpressionHelper.GetRouteInfoFromExpression(helper.RouteCollection, action);

            return(helper.RouteLink(linkText, routeInfo.Key, routeInfo.Value, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)));
        }