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

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to 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.

Tags

Was this article helpful?