Forcing the views to update in ASP.NET Core 3.1.10
-
I have an Asp.Net Core web application with some simple pages. I have a shared layout with the page content rendered as follows:
@RenderBody()
The problem is that when I make changed to the content, they don't appear when I debug the web site, which means that it is impossible to for me to work on the web site. I found some suggested fixes online. I updated the startup as follows:
public void ConfigureServices(IServiceCollection services) { System.Data.Common.DbProviderFactories.RegisterFactory("System.Data.SqlClient", System.Data.SqlClient.SqlClientFactory.Instance); var mvcBuilder = services.AddControllersWithViews();
#if DEBUG
if (IWebHostEnvironment.IsDevelopment())
{
mvcBuilder.AddRazorRuntimeCompilation();
}
services.AddRazorPages().AddRazorRuntimeCompilation();
#endif
services.Add(new ServiceDescriptor(typeof(Services.IKeyManagerFactory), new Services.KeyManagerFactory()));
services.AddMvc();
}But that doesn't help. I have tried other suggested fixes with no joy. For example in the startup Configure method:
app.UseStaticFiles(new StaticFileOptions() { OnPrepareResponse = context => { //context.Context.Response.Headers.Add("Cache-Control", "no-cache, no-store"); context.Context.Response.Headers\["Cache-Control"\] = "no-cache, no-store, must-revalidate, max-age=0"; context.Context.Response.Headers.Add("Expires", "-1"); } });
How do I force the views to update?