Header add

 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:

  1. Install the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet package.

  2. Update the project's Startup.ConfigureServices method to include a call to AddRazorRuntimeCompilation. For example:



public void ConfigureServices(IServiceCollection services)
{
    services.AddRazorPages()
        .AddRazorRuntimeCompilation();
}

For more details you can see this Video link




Post a Comment

Previous Post Next Post