Skip to content

Instantly share code, notes, and snippets.

@mattkruskamp
Created August 7, 2012 23:18
Show Gist options
  • Save mattkruskamp/3290450 to your computer and use it in GitHub Desktop.
Save mattkruskamp/3290450 to your computer and use it in GitHub Desktop.
Automatically Breaking Js and Css Cache Using Build Number in Asp.Net
public static string BuildNumber(this HtmlHelper html)
{
if (html.ViewContext.HttpContext.Cache["_buildnumber_"] == null)
{
var version = System.Reflection.Assembly
.GetExecutingAssembly().GetName().Version;
html.ViewContext.HttpContext.Cache["_buildnumber_"] =
version.Build.ToString();
}
return html.ViewContext.HttpContext.Cache["_buildnumber_"].ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment