Welcome to the navigation

Proident, enim ut irure excepteur et nisi ut dolore commodo reprehenderit laboris est deserunt eiusmod labore duis cupidatat consequat, minim sed esse sunt aliqua, nulla. Amet, sint nisi ad nostrud et in magna ut dolor laborum, ipsum pariatur, occaecat dolore aliquip nulla dolore sit do eu quis dolor exercitation aliqua

Yeah, this will be replaced... But please enjoy the search!

EPiServer 9 block preview error "There is no build provider registered for the extension '.cshtml'."

I was updating EPiServer to EPiServer 9.7 and while I was at it I updated System.web.mvc to 5.2 as well. Unfortenatly the preview of blocks stopped working with the error "There is no build provider registered for the extension '.cshtml'.".

Fortunatly this was easy to resolve and I figured two ways to handle it. The simple solution is to set optimizeCompilations="false" in web.config on the system.web > compilation element.

<system.web>
  <compilation debug="true" targetFramework="4.5" optimizeCompilations="false" />
</system.web>

The (in my opinion better) other way is to specify the following assemblies in the compilation tag, it will also ensure correct intellisense during development

<system.web>
  <compilation debug="true" targetFramework="4.5" optimizeCompilations="true">
    <!-- In order to provide MVC Intellisense support during developement-->
    <assemblies>
      <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add assembly="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </assemblies>
  </compilation>
</system.web>

There, save and your block previews should work

The full error was

Server Error in '/' Application.

There is no build provider registered for the extension '.cshtml'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: There is no build provider registered for the extension '.cshtml'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.

Source Error: 


Line 13: @if (@Model != null)
Line 14: {
Line 15:     Html.RenderContentData(@Model, true);
Line 16: }

Source File: c:\Repos\Whatever.Web\Views\Blocks\PreviewBlock\PreviewBlockIndex.cshtml    Line: 15 

Stack Trace: 


[HttpException (0x80004005): There is no build provider registered for the extension '.cshtml'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.]
   System.Web.Compilation.CompilationUtil.GetBuildProviderTypeFromExtension(CompilationSection config, String extension, BuildProviderAppliesTo neededFor, Boolean failIfUnknown) +11713414
   System.Web.Compilation.BuildManager.CreateBuildProvider(VirtualPath virtualPath, BuildProviderAppliesTo neededFor, CompilationSection compConfig, ICollection referencedAssemblies, Boolean failIfUnknown) +62
   System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +457
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +350
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +146
   System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +11898914
   System.Web.Compilation.BuildManager.GetCompiledType(VirtualPath virtualPath) +21
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +87
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +375
Please note that this portal is a BETA site , I will continuously improve all functionality and performance during the coming weeks / the author