public override void RegisterArea(AreaRegistrationContext context) { var defaultUri = UrlProvider <EquipmentController> .GetRouteValues(c => c.Index()); context.MapRoute( "Items_default", "Items/{controller}/{action}/{id}", new { area = defaultUri["area"], controller = defaultUri["controller"], action = defaultUri["action"], id = UrlParameter.Optional } ); }
public static MvcForm BeginForm <TController>(this HtmlHelper htmlHelper, Expression <Action <TController> > expression, object htmlAttributes) where TController : Controller { var urlParts = UrlProvider <TController> .GetRouteValues(expression); var controller = urlParts["controller"].ToString(); var action = urlParts["action"].ToString(); return(htmlHelper.BeginForm(action, controller, FormMethod.Post, htmlAttributes)); }
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapMvcAttributeRoutes(); var defaultUri = UrlProvider <EquipmentController> .GetRouteValues(c => c.Index()); // Register an empty route to fix Area default route registration problems var defaultRoute = routes.MapRoute( name: Default, url: "", defaults: new { area = defaultUri["area"], controller = defaultUri["controller"], action = defaultUri["action"], id = UrlParameter.Optional } ); // area data token needs to be set for areas to work properly defaultRoute.DataTokens["area"] = defaultUri["area"]; routes.MapRoute( name: Default_NoArea, url: "{controller}/{action}/{id}", defaults: new { action = defaultUri["action"], id = UrlParameter.Optional } ); }
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) { var redirectRoute = UrlProvider <ErrorsController> .GetRouteValues(c => c.UnauthorizedError()); filterContext.Result = new RedirectToRouteResult(redirectRoute); }
private static RouteValueDictionary GetRouteValues <TController>(this Expression <Action <TController> > expression) where TController : Controller { return(UrlProvider <TController> .GetRouteValues(expression)); }