Aleksa Ristic
Aleksa Ristic

Reputation: 2499

VS 2019 changes not visible before re-debugging project

So i have just upgraded to Visual Studio 2019 and created new ASP.NET Core project. There i have added some views/css and i hit Debug.

Problem comes when i change some code in .cshtml or .css while debugging is on. I refresh my page in browser and it doesn't load new content inside that file. It was totally normal thing in 2017.

What to do?

Upvotes: 2

Views: 1828

Answers (1)

Xueli Chen
Xueli Chen

Reputation: 12705

It's a known issue in Visual Studio 2019 ,try the following steps:

  1. Install the latest version of Visual Studio 2019 16.3.7 .

  2. For change some code in .cshtml

    (1) Asp.net core 2.2 , you could load the new content after refreshing the page in browser.

    (2) Asp.net core 3.0

    • Add NuGet package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
    • Update startup.cs services.AddControllersWithViews().AddRazorRuntimeCompilation();
  3. For getting the last version of js and css files , you should add asp-append-version="true" to your file references like:

    <link rel="stylesheet" href="~/css/site.css" asp-append-version="true"/>
    

    Reference:https://forums.asp.net/t/2154606.aspx?CSS+style+change+not+updated+on+the+website+until+browser+history+is+cleaned

Upvotes: 6

Related Questions