ASP.NET Razor views are not updating when simply updating html

坚强是说给别人听的谎言 提交于 2020-01-03 17:02:15

问题


ASP.NET Razor views are not updating when simply updating html. I'm trying to add a few elements on a page when my application is running in debug mode, and the changes are not being seen in the browser when I refresh the page. However, if I stop and restart the application, the changes are seen.

I've tried disabling cache, sending back headers (pragma no-cache), shift reload on the browser, nothing seems to work.

This is quite frustrating having to continually bounce the app.

What I'm using: asp.net 4.5, IISExpress, visual studio 2013.

Does anyone know how to turn off the output cache so I can debug without having to restart the entire application?

thanks


回答1:


As of September 2019, there's a bug in visual studio which prevents razor views from updating unless you restart the server after every update. Very annoying!

To fix:

1- Add the NuGet package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation

2- Modify the ConfigureServices method in startup.cs

Replace

 services.AddControllersWithViews();

with

 services.AddControllersWithViews().AddRazorRuntimeCompilation();



回答2:


Try hitting CTRL+F5 on the web page. The old files may be cached by your browser.

See this question for more details: Get rid of [dynamic] JavaScript views in Visual Studio



来源:https://stackoverflow.com/questions/25775246/asp-net-razor-views-are-not-updating-when-simply-updating-html

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