I have code that runs on application start that prefixes all of my routes with a {lang} parameter.
The intent is to transform any URL like /page to {lang}/page, with {lang} being a language code ("en", "fr"...).
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapMvcAttributeRoutes();
foreach (var r in routes.OfType<Route>())
r.Url = "{lang}/" + r.Url;
}
This works fine on ASP.NET MVC 5.0. For example this action shows the About page on both /en/about-us and /fr/about-us:
[Route("about-us", Name = "About")]
public ActionResult About()
{
return View();
}
(the {lang} parameter is read in OnActionExecuting and sets the UI culture accordingly.)
However, it no longer works on ASP.NET MVC 5.2.3.
On this version, the page remains accessible on /abous-us, and /en/about-us and /fr/about-us return a 404.
It is like the modified routes are not taken into account.
I tried to dig into MapMvcAttributeRoutes to troubleshoot but it looks like the code, and in particular the AttributeRoutingMapper class, was completely rewritten between the 2 versions.
Is there anything I can do to have my modified routes taken into account?
RegisterRoutes? You haven't provided a minimal reproducible example.