14

I used to be able to make changes to an ASP.NET (Core) MVC View and just hit refresh in the browser to apply the HTML (or Razor) changes.

Starting with ASP.NET Core 3.0 it seems I always have to restart the MVC application to get the latest changes in my browser.

This is my application configuration

public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); } 

1 Answer 1

29

Adding the NuGet package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation to the project and changing this line fixed it:

services.AddControllersWithViews().AddRazorRuntimeCompilation(); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.