4

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.

HaBo
  • 13,999
  • 36
  • 114
  • 206

1 Answers1

18

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();
HaBo
  • 13,999
  • 36
  • 114
  • 206