Reputation: 20648
Is there a way to declare a common route for Razor Pages, for example I have Foo.cshtml
which can be accessed by any of the following Url:
/foo
/en/foo
/fr/foo
/bar/foo
Note: I want this to be applied to all other Razor Page in the project as well.
So I found a solution, however, I want a custom route handler as well, that is, when user lands on the url, depends on the Url, I want to perform different works (changing Thread Culture for example)
Upvotes: 0
Views: 150
Reputation: 1106
you can add a route like
routes.MapRoute("DefaultLocalized",
"{language}-{culture}/{controller}/{action}/{id}",
new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional,
language = "en",
culture = "US"
});
Upvotes: 1