Priorities for resolving views

Sitefinity CMS uses a strict convention for resolving the views for widgets. This article describes the different ways to add a view to a widget and what are the priorities for the different approaches.

Priorities for resolving views

Following is a list of the different ways to resolve views for widgets. The list is ordered by priority from highest to lower:

Location of view Description 
ResourcePackages folder 

All resource packages, such as Bootstrap, Minimal, and so on, are located in this folder. For more information, see Overview: Resource packages.

The ResourcePackages folder is located in the root of the project: ~/ResourcePackages/

MVC folder

After  the ResourcePackages folder, Sitefinity CMS searches for your widget template in the MVC folder, located in the SitefinityWebApp project. To match the views with their respective widget, when naming the views, you must follow the naming convention ~/MVC/Views/ContentBlock/[ViewName].[extension]

The extension of the template file depends on your view engine. For Razor the extension is .cshtml, for WebForms the extension is .aspx.

Widget templates section 

MVC widget templates can be reused.
Sitefinity CMS first searches for your widget templates in the Design » Widget Templates section in the backend. By default, only templates of dynamic modules are automatically added on top the Widget templates section in the backend. You can create a custom widget template, as well, following the naming conventions. For more information, see Work with widget templates.

For example, the List.NewsList template is the list template of the News widget. If you have a file with List.NewsList  name in [YourPackage]/MVC/Views/News folder, Sitefinity CMS loads the template from this folder. In case there is no such template in this location, Sitefinity CMS searches for a template with the same name in the Design » Page templates section in the backend. If there is no template with this name in this location, Sitefinity CMS gets the default template from the assemblies. 

Embedded resources  By design, the MVC widgets that come out-of-the-box, such as Navigation, Content Block, or News, have corresponding assemblies that are referenced by the SitefinityWebApp. In each of the assemblies, the views have their Build action set to Embedded resource. This way all views are included in the assemblies. This is the final place where Sitefinity CMS searches to resolve the widget view. 

Priorities for resolving assets

Telerik.Sitefinity.Frontend.FrontendService service registers a virtual path for each widget assembly and for Telerik.Sitefinity.Frontend itself. The service also registers a route handler. This way, an HTTP GET request to the same file returns it as a response: ~/Frontend-Assembly/[Assembly-Name]/[Path]

The contents of a virtual file inside the Frontend-Assembly path can come from the file system at location ~/[Path] When not found there, it falls back to retrieving the contents of an embedded resource placed on the same path, inside the specified assembly. For example, ~/Frontend-Assembly/Telerik.Sitefinity.Frontend/Mvc/Scripts/Angular/angular.min.js

If a file ~/Mvc/Scripts/Angular/angular.min.js exists, then it will be retrieved. Otherwise, the embedded resource Telerik.Sitefinity.Frontend.Mvc.Scripts.Angular.angular.min.js is returned.

Additional resources

External links

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

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.

Web Security for Sitefinity Administrators

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.

Foundations of Sitefinity ASP.NET Core Development

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.


Was this article helpful?