asp.net core 2.2 production environment to directly update the View page with immediate effect

 

Sometimes we will update the page directly in the production environment file, such as changing the JS code, copy the CSS code or page layout. This situation did not change to the code-behind page in general is directly released files, core previous version 2.2 in asp.net (no active configuration page cache) update will take effect immediately, but in the 2.2 and later in the production environment in order to take effect immediately you have need to manually configure the following code:

1             services.AddMvc(options =>
2             {
3                 options.Filters.Add(new GlobalExceptionFilter());
4             }).AddJsonOptions(options =>
5             {
6                 options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
7             }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
8               .AddRazorOptions(options => options.AllowRecompilingViewsOnFileChange = true);

Main sentence: .AddRazorOptions (options => options.AllowRecompilingViewsOnFileChange = true); 

You can see from the attribute name means is almost out of view to allow the file to recompile the changes (on the importance of standardized naming)

Microsoft Docs https://docs.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-2.2

This article is to be recorded, if any help please leave a message like oh ^ _ ^ point

Guess you like

Origin www.cnblogs.com/Ax0ne/p/Allow_Recompiling_Views.html