When developing widgets with Sitefinity CMS and MVC, the Details and Index controller actions have a special meaning. Index action acts as Master in a Master/Detail scenario; Details displays one specific item based on the URL. All content in Sitefinity CMS has an UrlName. Some content data providers also define a specific URL format that dictates how items' URLs are generated, relative to the page where the content widget is placed. For example, News items have publication date placed before the UrlName segment of the URL. This article describes how Sitefinity CMS can resolve the requested item in the most consistent way.
Details
Index
Master
UrlName
Throughout the article, you can refer to the following code examples in the GitHub repository to get an understanding of how to work with the Index and Details actions:
Index action with first parameter of type int? is invoked when the current URL has one integer after the page URL. This is an exception to the default routing of the MVC widgets where you have to add a URL segment with the action name before its parameters. You can refer to the Index action in the provided code examples to understand how to use the route for paging.
int?
Details action with first parameter of type that implements Telerik.Sitefinity.Model.IDataItem is invoked when the URL of the page matches the URL of an item of the specified type. In the News controller example, the Details action is invoked when the URL of the News item matches the current URL. Sitefinity CMS passes that item as a parameter to the action. Optionally, your action can have a second parameter string redirectUrl. If the current URL is one of the additional URLs of the item, Sitefinity CMS passes the default URL of the item and it is set to redirect to the default one.
Telerik.Sitefinity.Model.IDataItem
string redirectUrl
In the Dynamic content controller example, take a look at the Details action. By convention, Sitefinity CMS searches for dynamic content with the name of the controller. In this case - Author. Because namespace is disregarded, in case of multiple Author dynamic content types, the first active module is taken.
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