Implementing routing

Kentico Xperience MVC websites respond to incoming requests using standard ASP.NET routing. ASP.NET routing is a pattern matching system that is responsible for mapping incoming browser requests to specified controller actions. When the MVC application launches, it registers one or more patterns within the framework’s route table to tell the routing engine what to do with any requests that matches those patterns.

Xperience provides two mutually exclusive routing schemes you can use for your projects:

  1. Content tree-based routing (recommended)
  2. Custom routing

You can set your preferred Routing mode in the Settings application, in the URLs and SEO category under the Routing section.

Additionally, you can use the alternative URLs functionality to make pages accessible under any desired URLs.

Content tree-based routing

With content tree-based routing, the system automatically generates and matches page URLs based on their position in the website’s content tree. You do not need to manually map any route templates in the MVC application. All routing logic is handled for you by the system. For more advanced routing scenarios, you can implement custom controllers and actions that take over the handling for specified requests, allowing you to inject custom logic into the routing process.

See the Content tree-based routing section for more information.

Custom routing

A routing model independent of the Xperience application. All routing on the MVC site needs to be implemented manually using standard ASP.NET routing functionality. To make Xperience pages available under custom routes, you need to set URL patterns for page types. The URL patterns must match route templates you register in the MVC application. Moreover, you can give content editors control over a part of the page URL via the page alias field or other custom parameters.

See the Custom routing using URL patterns section for more information.

Alternative URLs

Alternative URLs allow individual pages to become available under any number of URLs. Depending on the site’s configuration, the system either redirects to the page’s main URL or displays the page content under the submitted alternative URL.

This feature can be used together with either routing mode.