Since ASP.Net Core version 3.0 and higher:
A) Editing a Razor View (.cshtml) file while running the application does not apply the changes until restart.
B) Looks like edit and continue is not working.
IDE and Version: Microsoft Visual Studio 2019
Enable runtime compilation at project creationIn the Create a new ASP.NET Core web application dialog: Select either the Web Application or the Web Application (Model-View-Controller) project template. Select the Enable Razor runtime compilation checkbox.
Razor Pages is the default for building server-side web applications in ASP.NET Core. Components within the underlying MVC framework still have their uses such as using controllers for building RESTful APIs.
Open project in VS Code Shut down your application using Ctrl+C . Open your project in VS Code using one of the following options: Select File > Open Folder, and then select the RazorPagesMovie folder. Enter the following command in the terminal code .
Please use NuGet package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation Version 3.1.7 that is compatible with ASP.Net Core 3.1 and apply following line of code in Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.AddControllersWithViews().AddRazorRuntimeCompilation();
}
For this issue, I suggest you try to install package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
and then configure AddRazorRuntimeCompilation
in Startup.cs
like
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews().AddRazorRuntimeCompilation();
}
For this issue, you could trace by Breaking changes to runtime compilation for Razor views and Razor Pages #343
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With