1

We added a theme to our web forms project. There are two parts to this.

  1. We defined a theme (more information about this here) by adding a file to the project.
  • MyProject
    • app_themes
      • MyTheme
        • MyStyleSheet.css
  1. We applied the theme (more information about this here) by editing our web.config.

<pages theme="MyTheme" styleSheetTheme="MyStyleSheet">

Now all of our pages have the same style (which is great). However, we have another problem. When we update our style sheet, the changes are not reflected immediately in the browser. This is because most browsers implement caching by default. This is undesirable, so I started looking for solutions.

I found a solution: How to prevent CSS caching on a web page? By adding a query string to the end of the link, the browser thinks that it is a new file, and retrieves it. This won't work for us because we don't reference our style sheet like that. We don't have links to the style sheet on every page. We stuck our style sheet under app_themes, modified our web.config, and let ASP.NET apply it to every page for us.

We want to force the browser to get an updated css when we make a new build. What is the best way to accomplish that?

Community
  • 1
  • 1
Rainbolt
  • 3,542
  • 1
  • 20
  • 44
  • you should versioning your css file inside Theme folder – ale Jul 17 '15 at 19:04
  • @Infer-On Please avoid answering questions in comments. If you have an answer, post it as an answer so that others (including myself) can vote on it, improve it, comment on it, etc. (I do appreciate the help - just trying to point you to the correct place to post it.) – Rainbolt Jul 17 '15 at 19:05
  • this is why I have put only a comment ;) good work – ale Jul 17 '15 at 19:21

1 Answers1

0

What you are looking for is called Bundling. It is popular in the MVC side of ASP.NET but it is also available with web forms. Bundling will automatically minify and create a query string when you make changes so that the browser knows when to download the new file.

Following this guide should help. http://blogs.msdn.com/b/rickandy/archive/2012/08/14/adding-bundling-and-minification-to-web-forms.aspx

Andres Castro
  • 1,848
  • 16
  • 16