且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

更改后.NET Core MVC页面不刷新

更新时间:2023-12-03 12:40:58

ASP.NET Core 2.2似乎有所更改(而且我找不到有关此更改的任何公告。 )。如果您未明确在开发环境中运行,则将编译剃刀视图,并且不会看到对.cshtml

There was a change made in ASP.NET Core 2.2 it seems (and I can't find any announcements about this change). If you are not explicitly running in the 'Development' environment then the Razor Views are compiled and you will not see any changes made to the .cshtml

所做的任何更改。您可以关闭

You can however turn off this using some config in your Startup class as follows.

services.AddMvc().AddRazorOptions(options => options.AllowRecompilingViewsOnFileChange = true);

对于ASP.NET Core 3.0及更高版本,请参见Alexander Christov的答案

For ASP.NET Core 3.0 and higher, see Alexander Christov's answer.