I googled a lot but still got no luck.
This is my RouteConfig.cs
.
routes.MapRoute("BackRoute", "back/{controller}/{action}"
,new { controller = "Home", action = "Index" });
routes.MapRoute("Default", "{controller}/{action}"
,new { controller = "Home", action = "Index" });
As you see,There is the same parameter but I've business logic to choose between BackRoute
and Default
from code behind.
Can I change route from ActionFilterAttribute
?
public override void OnActionExecuting(ActionExecutingContext filterContext){
bool logic = true;
RouteValueDictionary rvd = filterContext.RouteData.Values;
if(logic){
filterContext = new RedirectToRouteResult("BackRoute",
new RouteValueDictionary(new {
controller = rvd["controller"].ToString()
, action = rvd["action"].ToString() }));
}
}
Can you guys suggest me the good way to achieve this goal ?
Thank you in advance,
Peace