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.
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.
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:
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.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important
Copyright © 2023 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, Ipswitch, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.
Powered by Progress Sitefinity