javascriptvisual-studioblazorblazor-server-side

Changes to js file not picked up for Blazor server app


I just noticed a strange behavior in Visual Studio 22 ver 17.11.5.

If I add a function to .js file, add a call to the function on a razor page and hit F5, I get an exception that the method cannot be found. This used to work just fine.

If I hit F12 and check the js file, it sure enough does not contain the newly added function.

If I add a new .js file and add it to _Layout.cshtml it works for a little bit. That is, I can add new functions and they are picked up, but at some random point, changes to this new file also stops being picked up.

Anyone else seeing this?


Solution

  • The issue is mainly related with cache instead of visual-studio

    If I hit F12 and check the js file, it sure enough does not contain the newly added function.

    The js file is still the one cached in your browser ,the one you've modified hasn't been downloaded

    You could clear the cache and try again or append a version query string like this issue