.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

Dynamic Mega Menu With Asp.Net with c#,java script and Sql Server.

Bootstrap Modal Popup keep open on PostBack in ASP.Net

Export div content to PDF Using ITextSharp in asp.net