.NET Core 3.0: Razor views don't automatically recompile on change


In this article i will provide the solution how to recompile asp core 3.0 application and show the changes on browser when we change something in Razor (views)  while debug mode .



Applications that require runtime compilation or re-compilation of Razor files should:

  1. Add a reference to the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package. It'll be available as part of the 3.0.0-preview3 release.
  2. Update the application's ConfigureServices to include a call to AddMvcRazorRuntimeCompilation:


  public class Startup

    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().AddRazorRuntimeCompilation();
           
        }
}

Comments

Popular posts from this blog

Bootstrap Modal Popup keep open on PostBack in ASP.Net

Resolved Issue in Asp core 3.0 serializersettings does not exist in AddJsonOptions

.Net most asked interview questions for experienced professionals (C#,Asp WEBFORM,MVC,ASP CORE,WEB API,SQL Server,Java Script,Jquery)