I was testing with .Net CORE 2.2 projects and if I modified something in the views I could see the changes automatically reflected without having to stop the execution or recompile. However, I upgraded to .Net CORE 3.0 using razor pages and when I change the view and save I have to stop the execution, compile again and run in order to see the changes reflected, is this normal?
The behavior you describe is normal and is due to a cleanup of the ASP.NET Core framework to remove dependencies on Roslyn (C# and VB.NET compiler). For this reason, the ability to recompile views and Razor pages has been extracted to a nuget package. The most up-to-date information on this is at the following link: https://github.com/aspnet/AspNetCore/issues/7647 .
Starting with .NET Core 3 Preview 3, it is possible to add the ability to recompile Razor to our ASP.Net Core projects. For this we must:
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
( nuget package ).Update
ConfigureServices
our app's method to include a call to theAddRazorRuntimeCompilation
or methodAddMvcRazorRuntimeCompilation
. The name of the method depends on the version of .NET Core 3 preview that we are using.This example shows how to call the method if we are using MVC:
and this would be for Razor pages: