Build required for CSHTML changes, JS changes in ASP.NET MVC Core 3.1 Applications [duplicate]

天涯浪子 提交于 2020-03-17 03:14:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!