hi, i defined two routes in global.asax like below
context.MapRoute("HomeRedirect", "",
new
{
controller = "Home",
action = "redirect"
});
context.MapRoute("UrlResolver", "{culture}/some",
new
{
culture = "en-gb",
controller = "someController",
action = "someAction"
},
new
{
culture = new CultureRouteConstraint()
});
according to above definition, when user request mysite.com/ redirect action of HomeController should be called and in that:
public class HomeController : Controller
{
public ActionResult Redirect()
{
return RedirectToRoute("UrlResolver");
}
}
i want to redirect user to second defined route on above, so also i specified default values for that and some Constraint for each of those. but when RedirectToRoute("UrlResolver") turns, no default values passed to routeConstraints on second route and No route in the route table matches the supplied values shows.
update
my CultureRouteConstraint:
public class CultureRouteConstraint : IRouteConstraint
{
bool IRouteConstraint.Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
try
{
var parameter = values[parameterName] as string;
return (someCondition(parameter));
}
catch
{
return false;
}
}
}
now values parameter haven't culture key/value, but route parameter have that.