Click here to Skip to main content
15,390,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have just started some web development, using ASP.NET in Visual Studio 2019. When I run the site in the built-in IIS, the CSS does not appear to reload.

I have set the build actions on the CSS files to be Content and Copy Always.

Even refreshing the default Edge browser does not work.

If I press CTRL-F5 for a complete refresh, this does work, but it seems a bit clunky to have to do this. Am I missing something?

What I have tried:

I have also tried a complete rebuild of the solution but this doesn't seem to make any difference.
Updated 9-Jun-21 18:38pm

1 solution

The browser is caching the CSS files. You need to append a cache-buster to the URL to force them to reload. Typically, this would be a value computed from the last modified time of the source file, or a hash computed from the contents of the file, so that it can continue to be cached until it actually changes.

How you do that will depend on the framework you're using. For example, in ASP.NET core, you would do this by adding asp-append-version="true" to your <link> element.
Patrick Skelton 5-Feb-21 3:36am
Thank you for the information. Do you know how to do it in ASP.NET, not .Core?

I'd have thought IIS might have had a command-line option or config file option that VS might be able to make use of, though I guess forcing it to always reload resources might make the already-slow deployment to local IIS even slower.
Richard Deeming 5-Feb-21 3:38am
MVC or WebForms?
Patrick Skelton 5-Feb-21 3:39am
Sorry - MVC.
Richard Deeming 5-Feb-21 3:47am
Patrick Skelton 5-Feb-21 3:53am
An example of not being able to Google something 'cos I honestly didn't know it was referred to as 'auto-versioning', nor did I realise the bundling process solves this problem. So I've learnt three things! Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900