Skip to content

Instantly share code, notes, and snippets.

@mattkruskamp
Created August 24, 2015 08:31
Show Gist options
  • Save mattkruskamp/eceabd2367d444f541e4 to your computer and use it in GitHub Desktop.
Save mattkruskamp/eceabd2367d444f541e4 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