asp.net - How to programmatically clear outputcache for controller action method -


If there is a specified output cache attribute on an action in the controller action, then there is a way to clear the output cache without restarting IIS

  [OutputCache (duration = 3600, VaryByParam = "param1; param2")]? Public string AjaxHtmlOutputMethod (string param1, string param2) {var someModel = SomeModel.Find (param1, param2); // Set up ViewData ... Return RenderToString ("ViewName", some models); }  

I'm looking into using the HttpResponse.RemoveOutputCacheItem (string path) to make it clear, but I have trouble finding out for what path Getting it done in the action method map it I'm going to try again with the aspx page that is provided by ViewName.

Maybe I'm just manually entering RenderToString in the output HttpContext.Cache instead if I can not understand this one

Update

Please note that the output cache is VaryByParam, and the test of a hardcoded path "/ controller / action" does not actually clear the output cache, So it seems that it matches "/ controller / verb / param 1 / paragraph 2".

This means that I have to return to object level caching and manually cache the output for RenderToString () : (

< P>

try it

  var urlToRemove = Url.Action ("AjaxHtmlOutputMethod", "Controller"); HttpResponse RemoveOutputCacheItem (urlToRemove);  

Update:

  on requestContext = New System.Web.Routing.RequestContext (New HttpContextWrapper ( System.Web.HttpContext.Current); New System.Web.Routing.RouteData ()); URL = new UrlHelper (requestContext);  

Renewed:

Try this:

  [OutputCash (location = system.us.UI.Output's location.Sir, durat, otherwise the cache extinction will not work because you have cached the HTML output on the user's machine   < / Code> 

div>

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -