I would like to override Url.Content to append a query string parameter to the resulting string on Url.Content.
The reason being, I have a web application that I develop, and with each release, users must clear their cache to get the new css and js. A solution for this is to append a version number to the querystring to force loading of the new version.
A working solution is as follows:
@{ var version = "?v=" + ViewBag.VersionNumber; }
<head>
<link href="@Url.Content("~/ux/css/base.css")@version" rel="stylesheet" type="text/css" />
</head>
Version is set in a config file so with each release, the version is updated. I would like this to be more automatic though, as currently any time a new css reference is added, we must remember to add @version to the string. An extension method the returns the path with the version number already appended would be perfect.
Also, if anyone knows who I could make changing the version number automatic with TFS check-ins or compiles that would be really useful too.
You could do something like this:
Version Service could look something like this:
You might want to take a look at cassette
* EDIT *
For autom. build numbers with TFS, check out:
automatic-assembly-file-version-numbering-in-tfs-2010