SunilK
SunilK

Reputation: 157

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

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

Upvotes: 12

Views: 6711

Answers (2)

Ian Gibblet
Ian Gibblet

Reputation: 582

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();

Upvotes: 22

Zain Rizvi
Zain Rizvi

Reputation: 24656

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

Upvotes: -6

Related Questions