Is live reload with in-process aspnet core 3 possible?

Viewed 18355

I recently upgraded an .Net Framwork AspNet MVC app to a AspNet Core 3 MVC app and I'd like the ability to change a view, save, and refresh my browser window to see the changes. Now it appears I have to do a build every time before I can see any changes. Is there a way to change this behavior?

This is being hosted under IIS 10

4 Answers

As far as I know, the runtime compilation could just work in the develop environment. That means you couldn't use it in the production environment(which is hosted on the IIS).

If you change the visual studio's debug environment to IIS, it will stil work.

Besides, RuntimeCompilation is not a build-in feature in the asp.net core 3.0.

If you want to use it, I suggest you could try to install the package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation and then configure AddRazorRuntimeCompilation in Startup.cs like

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

After some search I found a very simple solution:

Add following reference to csproj:

<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.3" />

Add AddRazorRuntimeCompilation() to your services configuration

services.AddControllersWithViews().AddRazorRuntimeCompilation();
Related