Skip to content

Instantly share code, notes, and snippets.

@casper-rasmussen
Created March 20, 2016 22:28
Show Gist options
  • Save casper-rasmussen/87aec6bb089d9d1b0e66 to your computer and use it in GitHub Desktop.
Save casper-rasmussen/87aec6bb089d9d1b0e66 to your computer and use it in GitHub Desktop.
void PurgeOutputCacheByContent(IContent content)
{
IEnumerable<TemplateModel> templateModels = this._templateModelRepository.List(content.GetOriginalType());
RouteValueDictionary routeValues = new RouteValueDictionary();
routeValues.Add("currentcontent", content);
foreach (TemplateModel model in templateModels)
{
string controllerName = model.Name.Replace("Controller", "");
this._outputCacheManager.RemoveItems(controllerName, "Index", routeValues);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment