gpt4 book ai didi

asp.net-mvc - 如何在 Rider 中启用 View 热重载?

转载 作者:行者123 更新时间:2023-12-03 23:21:02 33 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





.NET Core MVC Page Not Refreshing After Changes

(14 个回答)


2年前关闭。




我正在使用 Rider 编写一个 MVC 应用程序,一个行为困扰着我:当我修改 View 时,我必须重建解决方案并重新启动它以查看更改。当我从浏览器重新加载网站时,是否可以直接看到修改后的 View ?

顺便说一句,IDE(或 dotnet?)不认为 View 更改是重建触发更改。我必须手动单击“重建选定项目”,然后才能启动应用程序的修改版本。这是为什么?

最佳答案

这不是 Rider 的问题,它基本上是 ASP.NET MVC Core 的工作原理。您需要启用 Razor runtime compilation .从文档(强调我的):

Razor files are compiled at both build and publish time using the Razor SDK. Runtime compilation may be optionally enabled by configuring your application.



请注意,默认情况下运行时不包含在此列表中。要更改此行为:
  • 添加 Nuget 包 Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation .
  • 更改您的 Startup.ConfigureServices包含运行时编译的代码:
    services
    .AddControllersWithViews()
    .AddRazorRuntimeCompilation();
  • 关于asp.net-mvc - 如何在 Rider 中启用 View 热重载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58300922/

    33 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com