5

I would like to be able to have a version number appended to a css file located in my app_themes folder in my asp.net website so that modification to the file would force the browser to get the file from the server instead of using the one in the cache.

the css output path would look like ~/app_themes/blue/blue.css?v=1234

Any idea how it can be done without having to manually edit the filename?

Assaf Lavie
  • 73,079
  • 34
  • 148
  • 203
ak3nat0n
  • 6,060
  • 6
  • 36
  • 59

3 Answers3

7

A more detailed solution is available here:
Add url parameter to css file in asp themes folder

Community
  • 1
  • 1
Nariman
  • 6,368
  • 1
  • 35
  • 50
4

I'd try something like this

<link 
  rel="stylesheet" 
  href="/app_themes/blue/blue.css?v=<%=Global.VERSION_NUM%>"> 

Do that to all your CSS references, then when you make a deployment to your live site, you can just change the constant VERSION_NUM

Clyde
  • 8,017
  • 11
  • 56
  • 87
  • 8
    Not sure why this was marked as the correct answer - as far as I can tell, CSS from App_Themes is automatically added to the rendered page so you can't change a version number like this unless you add duplicate references to the same stylesheet. – ajbeaven Sep 16 '12 at 09:30
1

IT would be easy and best concept to implement css versioning in .net application by below concept

<link href="<%="../../App_Themes/Base/css/main.css?v="+ DateTime.Now.ToString("yyyyMMddhhmmss") +""%>" rel="stylesheet" />
SantoshK
  • 1,789
  • 16
  • 24