问题
I have recently upgraded my ASP.NET MVC Core 2.2 application to Core 3.1, everything works well, but in debug sessions if I make any changes to CSHTML
file, like adding a new HTML tag or change code in JS file, it doesn't reflect by refreshing the app on localhost debug session. I will have to stop my VS and re-build and run in debug mode.
This is happening only for ASP.NET Core 3.1 in other projects I have with ASP.NET Core 2.2 for any CSHTML changes I don't have to rebuild the solution.
I am using Microsoft Visual Studio Enterprise 2019 Version 16.4.1
Any help is greatly appreciated.
回答1:
Found answer on SO: .NET Core 3.0 - Preview 2 - Razor views don't automatically recompile on change
Install NuGetpackage Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
update startup.cs with
services.AddControllersWithViews(x=>x.SuppressAsyncSuffixInActionNames = false)
.AddRazorRuntimeCompilation();
来源:https://stackoverflow.com/questions/59302247/build-required-for-cshtml-changes-js-changes-in-asp-net-mvc-core-3-1-applicatio