Reputation: 33
i'm using visual studio code on mac osx for running a simply web app in asp net core 3.1. I run application with command dotnet run in visual studio code terminal. Now, if i modify a .cshtml template and refresh my browser, modify don't show.
Why? How can i resolve?
Thanks
Upvotes: 1
Views: 2086
Reputation: 20106
To enable runtime compilation in vs code, you need to follow below steps:
1.Add a reference to the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
package,run the command in the terminal
dotnet add package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation -v 3.1.0
2.Update the project's Startup.ConfigureServices
method to include a call to AddRazorRuntimeCompilation
.
services.AddControllersWithViews().AddRazorRuntimeCompilation();//for MVC
//services.AddRazorPages().AddRazorRuntimeCompilation();//for Razor Pages
Upvotes: 3