除非重新启动项目,否则 VS .Net Core Razor 页面不会更新
VS .Net Core Razor pages do not update unless project is re-started
我在 VS 2019 中有一个简单的 .Net Core 3.1 项目。我在 VS 中编辑一个 cshtml 文件,而项目是 运行(即设置边框颜色或添加标签)。在 MVC 下,我可以刷新浏览器 window 并且更新会被反映出来。我可以立即看到更改的结果。现在我必须重新启动项目并导航到我的页面以查看更改。非常令人沮丧。是否有针对此行为的修复?
微软在文档中提到要添加运行时编译。
Runtime compilation may be optionally enabled by configuring your application.
添加Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation包。
更新Startup.cs
public void ConfigureServices(IServiceCollection services)
{
IMvcBuilder builder = services.AddRazorPages();
builder.AddRazorRuntimeCompilation();
...
我在 VS 2019 中有一个简单的 .Net Core 3.1 项目。我在 VS 中编辑一个 cshtml 文件,而项目是 运行(即设置边框颜色或添加标签)。在 MVC 下,我可以刷新浏览器 window 并且更新会被反映出来。我可以立即看到更改的结果。现在我必须重新启动项目并导航到我的页面以查看更改。非常令人沮丧。是否有针对此行为的修复?
微软在文档中提到要添加运行时编译。
Runtime compilation may be optionally enabled by configuring your application.
添加Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation包。
更新Startup.cs
public void ConfigureServices(IServiceCollection services)
{
IMvcBuilder builder = services.AddRazorPages();
builder.AddRazorRuntimeCompilation();
...