macos - Asp net core 3.1 webapp doesn't refresh on modify razor template
问题描述
i'm using visual studio code on mac osx for running a simply web app in asp net core 3.1. I run application with command dotnet run in visual studio code terminal. Now, if i modify a .cshtml template and refresh my browser, modify don't show.
Why? How can i resolve?
Thanks
解决方案
To enable runtime compilation in vs code, you need to follow below steps:
1.Add a reference to the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
package,run the command in the terminal
dotnet add package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation -v 3.1.0
2.Update the project's Startup.ConfigureServices
method to include a call to AddRazorRuntimeCompilation
.
services.AddControllersWithViews().AddRazorRuntimeCompilation();//for MVC
//services.AddRazorPages().AddRazorRuntimeCompilation();//for Razor Pages
推荐阅读
- firebase - Flutter 中的 Firebase 消息传递
- jquery - Z-index 不适用于 datetimepicker django 小部件
- xcode - 如何在 Xcode 12.4 中保持提交/差异窗口的布局
- vue.js - 观看 nuxt-auth 令牌更改
- html - 仅在选中另一个框时如何使复选框“可选中”
- javascript - 在我的插槽中包装动态添加的子元素
- python - Python:按CSV中的唯一列合并重复项
- wordpress - woocommerce 下拉菜单中的可变产品价格
- javascript - Vue 2.0 渲染问题,当我实际提供不同的 id 时,它设置了 div id="1"
- javascript - 如何从 Cloud Functions 查询 Firestore 集合?