The asp.net core razor page cannot be updated in real time during debugging

Time:2021-10-6

. net core is currently a major cross platform architecture of. Net, so the common page in the. Net core project is the razor page, and we often modify the code while debugging to develop the project.     Unfortunately, by default,. Net core does not support us to see the effect while changing in the debugging process. This requirement is described in professional terms as:. Net core does not provide project runtime compilation by default.

 

So how can we achieve the function of runtime compilation to facilitate our development projects? Microsoft has already prepared nuget package for us.

 

Solution:

1 – add package source through nuget: microsoft.aspnetcore.mvc.razor.runtimecompilation;

2 – add the module to the startup.cs class file:

public void ConfigureServices(IServiceCollection services)
{
    //Add razor runtime compilation
    services.AddControllersWithViews().AddRazorRuntimeCompilation();    
}