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?}");
});
}
. NET Hot Reload applies code changes, including changes to stylesheets, to a running app without restarting the app and without losing app state. Hot Reload is supported for all ASP.NET Core 6.0 and later projects.
If the Browser is refreshed using F5 button after the Form is submitted (in other words after PostBack operation), the submitted data is resubmitted to Server.
Adding the NuGet package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
to the project and changing this line fixed it:
services.AddControllersWithViews().AddRazorRuntimeCompilation();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With