cshtml being cached, need to restart web.config for every change

1 month ago
Hi,

I am facing a difficulty when changing cshtml as I need to save web.config in order to see the HTML changes (please note this is not browser's cache).

Has anyone found a better way to refresh the cache after editing cshtml files avoiding long waiting?

Thank you in advance.
1 month ago
is this in a Dev or Production environment?  

In published environments I believe the cshtml files are compiled at runtime, so restarting the application should recompile the changes.  I think this addresses it: https://docs.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-3.1

In Dev you may need to do a force refresh depending on browser (ctrl+F5)
1 month ago
I think restarting the web application using IIS would be easier than changing the web.config file to restart the application.
1 month ago
This change has been made in ASP.NET Core 2.2. However you can turn off this by using some configuration in your Startup class.

services.AddMvc().AddRazorOptions(options => options.AllowRecompilingViewsOnFileChange = true);


The value of AllowRecompilingViewsOnFileChange determines whether to watch for file changes (on disk) or not. When it's true, MVC will watch for changes to cshtml files.

By default, the value is true for ASP.Net Core 2.1 or earlier, as well as the Development environment of later versions.  Otherwise the value is false.