Override the page strategies
Use this procedure to create a custom frontend strategy that will compile only specific frontend pages, instead of all the pages of the site, which is the default behavior. You do this by implementing the IPageKeyStrategy interface, then register it in Sitefinity's object factory during the Boostrapper.Bootstrapped event.
In the custom strategy, the method GetPageIds returns the IDs of the pages that will be precompiled. The following code is an example of a custom frontend strategy implementation:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using Telerik.Sitefinity.Modules.Pages;
using Telerik.Sitefinity.Pages.Model;
using Telerik.Sitefinity.Web.Compilation;
namespace SitefinityWebApp
{
class CustomFrontendPageKeyStrategy : IPageKeyStrategy
{
public IList<Guid> GetPageIds()
{
var siteRootId = Guid.Parse("1C6F7683-70C4-4A79-8443-78358FEEA91A");
var manager = PageManager.GetManager();
var ids = manager.GetPageNodes()
.Where(x => x.RootNodeId == siteRootId)
.Where(x => x.NodeType == NodeType.Standard)
.OrderBy(x => x.RootNodeId)
.Select(x => x.Id).ToList();
return ids;
}
}
}
The following code shows how to register the custom strategy:
C#
using System;
using Telerik.Microsoft.Practices.Unity;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Web.Compilation;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, System.EventArgs e)
{
ObjectFactory.Container.RegisterType<IPageKeyStrategy, CustomFrontendPageKeyStrategy>("Frontend");
}
}
}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
Get started with Integration Hub | Sitefinity Cloud
This free lesson teaches administrators, marketers, and other business professionals how to use Sitefinity Integration Hub to create automated workflows between Sitefinity and other business systems.
Web Security for Sitefinity Administrators
This free lesson teaches administrators the basics about protecting your Sitefinity instance and your 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 ASP.NET Core and take advantage of its decoupled architecture and modern development model.