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.

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?