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.
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.
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.
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.
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 © 2022 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