Create a precompiled resource package

Resource packages in Sitefinity CMS contain Razor templates. The templates are used for rendering views of MVC widgets. The templates in the resource packages are compiled when the corresponding widget is rendered. Because of this, there is a delay of several seconds before a widget is rendered for the first time while the web application is running.

To avoid the initial rendering delay, you can precompile the templates so that they are ready for rendering when the widget is requested. This article describes a process for precompiling resource packages.

Perform the following:

  1. In Visual Studio, create a new Class Library (.NET Framework) project.
  2. Install Telerik.Sitefinity.Feather NuGet package.
    To do this, in the Package Manager Console, run Install-Package Telerik.Sitefinity.Feather. You can find the latest NuGet packages in the NuGet repository.
  3. Move the MVC folder from the resource package, which you want to precompile, to the root of the created project and delete the ResourcePackages folder.
  4. Add the following .NET Framework references:
    • System.Runtime.Serialization
    • System.Web.ApplicationServices
    • System.Web.Extensions
  5. Install the following NuGet packages:
    • Install-Package Telerik.Sitefinity.Core
    • Install-Package Telerik.Sitefinity.ServicesImpl
    • Install-Package ServiceStack.Text
  6. Set the Build Action of all view template items in the project to Embedded Resource.
  7. Add the following attribute in the AssemblyInfo that marks the assembly as a resource package assembly:
    [assembly: Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.Attributes.ResourcePackage("Bootstrap")]
  8. Add the resulting assembly in the bin folder of your Sitefinity web app or reference it inside your Sitefinity web app project.

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?