There are some methods like the followings in UrlHelper class in MVC4
public string Action(string actionName, object routeValues);
public string Action(string actionName, RouteValueDictionary routeValues);
...but i want to change route values in every Action method calls
for this I wrote CustomUrlHelper
class like the following:
public class CustomUrl : UrlHelper
{
public CustomUrl()
: base(HttpContext.Current.Request.RequestContext,RouteTable.Routes){}
public string CustomAction(string actionName, string controllerName, string areaName, object routeValues, bool generateToken)
{
RouteValueDictionary rvd = new RouteValueDictionary(routeValues);
//some changes on route value dictionary
return Action(actionName,controllerName, rvd);
}
}
If we know action name controller name than every thing is OK, but if we just know a base URL and route value dictionary than my CustomAction
method does not work.
Let's say if I have just a linkbase like A/B/C/D and RouteValueDictionary
.
Now I want a method it gets baseUrl
and RouteValueDictionary
and produces complete link.