We are having serious issues in the startup (boot) time of our application.

After carefull investigation we have discovered that the most time is consumed by first-time-visit compilation of the cshtml files. This compilation can take up to 50 seconds per cshtml file.

We use Helix architecture with a lot of components. The combination of all those compilations takes ages and it can take up between 20 and 30 minutes for the site to boot. Once all cshtml have been hit once, the site speed and performance is ok.

Example: this cshtml takes 43 seconds to compile!

@using Sitecore.Mvc
@inherits System.Web.Mvc.WebViewPage
@inherits Glass.Mapper.Sc.Web.Mvc.GlassView<Feature.PageLayout.Models.PageSectionViewModel>

var sectionClasses = Model.Presentation.BackgroundColor != null ? Model.Presentation.BackgroundColor.CssClass : "";

<section class="section-box @sectionClasses">
    <div class="container">

We have tried to precompile our cshtml files. This was a major difference and we had the site cold started in under 3 minutes. Unfortunatly, we can only precompile our own code, and we don't have precompiled cshtml and aspx from Sitecore, causing the platform not to work giving the error that those pages are not precompiled. (e.g. login page, experience editor, ...) So precompilation is out of the option.

On IaaS platforms, we do not experience this compilation time of cshtml taking up so much time.

My question: Did anyone experience the same kind of issues? Are there any settings in Azure PaaS that we are missing?

  • Since Sitecore 8.2, most of the Speak views are precompiled and bundled in the assemblies (mainly Sitecore.Speak.Components.Web and Sitecore.Speak.Web). Which version of Sitecore are you using? – maz Sep 26 '18 at 17:39
  • 9.0-update 1 - you are correct in this, but this is not the standard .net framework compilation. They use razorgenerator to generate class files from their cshtml, which is then compiled. These classes are directly called instead of the cshtml's by tweaking the viewhandler binding. I have been trying to use leverage the same mechanism today, and my first results are possitive. – Bart Verdonck Sep 26 '18 at 21:06
  • What SKU is your WebApp and what DTU are your databases? – Mark Gibbons Sep 27 '18 at 0:43
  • What topology are you using? – Dylan Young Sep 27 '18 at 0:48
  • Also see if this applies to you kb.sitecore.net/articles/290593 – Mark Gibbons Sep 27 '18 at 0:54

To round up this topic, we ended up using the Razor Generator plugin of visual studio. https://github.com/RazorGenerator/RazorGenerator

And added the assemblies to the precompilation section in sitecore config. (This is the same method sitecore uses to speed up experience editor.)

<?xml version="1.0"?>
<configuration xmlns:x="http://www.sitecore.net/xmlconfig/" xmlns:env="http://www.sitecore.net/xmlconfig/env/">
  <sitecore env:require="!Local">
          <assemblyIdentity name="Feature.Jackpot" />

By default Sitecore doesn't use the Roslyn compiler nuget packages Microsoft.Net.Compilers and Microsoft.CodeDom.Providers.DotNetCompilerPlatform packages, and instead will use the version of Roslyn installed on the system.

I've seen a very noticeably improved compilation performance improvement when using the latest versions of those packages.


  1. Install the latest version of the nuget packages Microsoft.Net.Compilers and Microsoft.CodeDom.Providers.DotNetCompilerPlatform to all projects in the solution.
  2. Make sure your web.config is using the correct CodeDom configuration for the version you have installed. For example:


      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />

You'll also notice in the csproj files it will add a reference to the package

<Import Project="..\..\..\..\packages\Microsoft.Net.Compilers.2.9.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\..\..\..\packages\Microsoft.Net.Compilers.2.9.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="..\..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
  • This answer works as well. The combination of both solutions (precompile + use dotnetcompilerplatform) can give a good boost to startup performance. Adding DotNetCompilerPlatform made startup approx 50% faster. – Bart Verdonck Jan 18 at 12:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.