.NET Core MVC Page Not Refreshing After Changes

后端 未结 10 485
花落未央
花落未央 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:32

    There was a change made in ASP.NET Core 2.2 it seems (and I can't find any announcements about this change). If you are not explicitly running in the 'Development' environment then the Razor Views are compiled and you will not see any changes made to the .cshtml

    You can however turn off this using some config in your Startup class as follows.

    services.AddMvc().AddRazorOptions(options => options.AllowRecompilingViewsOnFileChange = true);
    

    For ASP.NET Core 3.0 and higher, see Alexander Christov's answer.

提交回复
热议问题