CTB
CTB

Reputation: 29

Can't change styles using Site.css

I am learning MVC 4 and am using one of the tutorial projects I've found. I'm at the point now where I'd like to play with styles, but am bewildered. I thought changing a style in site.css would do the job, but no matter what I do it's ignored. Here is the really weird part, though - when I delete the contents of site.css and run the project, everything looks like it did before I deleted the style code. I realize that I don't yet fully understand specificity, but Firebug tells me that the styles are coming from site.css.

Can anyone tell me how this could be?

Upvotes: 2

Views: 4562

Answers (2)

Iosua Sipos
Iosua Sipos

Reputation: 451

The web browser download web pages and store them locally in your computer, in cache memory. When you visit the second time that page, the browser loading the page locally from cache and not downloading everything again.

Sometimes we need to manually delete the cache because the browser fails to recover the most recent copy available on the Site. I'll show you how to do it in 2 ways

  1. Right-click on the refresh icon and choose the option "Hard Reload" or "Empty Change and Hard Reload".

enter image description here

  1. In Google Chrome go to History(Ctrl+H) -> Clear browsing data -> and select Changed images and files -> press button CLEAR DATA

The difference between them can be found at this link:

What's the difference between "Normal Reload", "Hard Reload", and "Empty Cache and Hard Reload" in chrome?

Upvotes: 2

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167162

This looks like the CSS has been cached by the browser. What you can do if this is the issue is:

  • Force reload all the resources by pressing Ctrl + F5.
  • Try to open the site again in Incognito or Private Browsing window, close all the windows, and then open again in Incognito or Private Browsing window.

You can check the source of the Site.css file by opening the URL from the browser and verifying the contents. If the contents are old and not updated, you can press Ctrl + F5 on the Site.css page to find the updated file and then pressing just F5 will display the updated styles.

Most common way to handle this in Visual Studio is:

  • Clean Solution
  • Build All

Upvotes: 4

Related Questions