I want to define a route with a constraint so that it only matches known controller names. This is to allow me to define a fallback route for other URLs of the same form.
Specifically:
/User
Should take me to the Index action of the User controller (which exists)
/History
Should take me to the Index action of the History controller (which exists)
/es
As no "es" controller exists, should use the fallback route and take me to the Index action of the Home controller with a language parameter value of "es".
I need this because I have a requirement to provide a special URL with a language code to launch the app in a given language. So there is now a need to distinguish between valid controller names and language names in the routing.
How can I implement RegisterRoutes
to achieve this? Many thanks!
Edit: I realize that I can define a specific route for each of my controllers, which is OK (I don't have a zillion controllers). But I'm wondering if I can rely on a generic constraint to achieve this so that I don't have to define individual routes.