Hello
I was planning on having 2char language in url, like something.com/EN, /ES, /US. Is that possible to add a 2char constraint for a route?
/M
Hello
I was planning on having 2char language in url, like something.com/EN, /ES, /US. Is that possible to add a 2char constraint for a route?
/M
Yes u can do this by routeconstraints. constaints can be passed to Maproutes method in global.asax. if u have a constraint that can be handled by regex u can write it like
routes.MapRoute(
"strict",
"{controller}.mvc/{docid}/{action}/{id}",
new {docid = "",action = "Index", id = ""},
new { docid = @"\d+"}
);
where regex pattern tells that docid should be numeric to match this route. however u can write ur own class that implements IRouteConstraint interface and object of that class can act as routeconstraint for ur route
take a look here to see how u can implement IRouteConstraint