With Sitefinity CMS, you can work with attribute routing in the context of Sitefinity CMS widgets. As a result of the integration with ASP.NET MVC 5, you can use the RelativeRoute attribute to work with attribute routing and attributes to define routes for controller actions.
RelativeRoute
NOTE: When using the RelativeRoute attribute on one of the controllers actions, all controller actions must be decorated with the attribute, as well.
The RelativeRoute attribute has the same constructors and properties as the stock Route attribute. Sitefinity CMS automatically maps all routes defined, using the attributes for both RelativeRoute and Route attributes. As a result, you do not need to call the MapMvcAttributeRoutes.
Route
MapMvcAttributeRoutes
The Route attribute, describes routes relative to the application path. The RelativeRoute attribute, on the other hand, describes routes relative to the page node where the widget is placed.
This example illustrates the difference between the two attributes. You have the following widget implementation:
If you add this widget to a page with an URL ~/my-page, then you get two routes:
~/my-page
~/my-page/my-sample-path
~/my-sample-path
NOTE: If there are any RelativeRoute attributes on your controller, then the default Sitefinity CMS autorouting handling and the convention-based routes are ignored. For more information, see For developers: Autorouting in pure and hybrid mode and Implement Master Detail content controllers.
You can also read the following tutorial about working with attribute routing: Create a Book widget.
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important