In this article we will learn how how to resolve the issue of Razor file compilation issue in ASP.NET Core.
Razor files with a .cshtml extension are compiled at both build and publish time using the Razor SDK. Runtime compilation may be optionally enabled by configuring your project.
Razor compilation
Build-time and publish-time compilation of Razor files is enabled by default by the Razor SDK. When enabled, runtime compilation complements build-time compilation, allowing Razor files to be updated if they're edited.
Enable runtime compilation in an existing project
To enable runtime compilation for all environments in an existing project:
Install the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet package.
Update the project's
Startup.ConfigureServices
method to include a call to AddRazorRuntimeCompilation. For example:
Post a Comment