Luke Vo
Luke Vo

Reputation: 20648

Common routes for Razor Page?

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:

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

Answers (1)

Venom
Venom

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

Related Questions