.NET Core MVC Page Not Refreshing After Changes

后端 未结 10 479
花落未央
花落未央 2020-12-04 10:09

I\'m building a .NET Core MVC on the latest version 2.2. I have a problem when I make changes to the CSHTML file and refresh the page, my changes are not reflected in the br

10条回答
  •  不思量自难忘°
    2020-12-04 10:42

    I've just created a new project using the latest ASP.NET MVC Core 3.1 template and I altered the following to get runtime recompilation enabled for Debug:

    Reference NuGet package - Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.

    Startup.cs - ConfigureServices(IServiceCollection services) WAS:

    // stuff...
    
    services.AddControllersWithViews();
    
    // more stuff...
    

    NOW:

    // stuff...
    
    var mvcBuilder = services.AddControllersWithViews();
    
    #if DEBUG
        mvcBuilder.AddRazorRuntimeCompilation();
    #endif
    
    // more stuff...
    

提交回复
热议问题