0

My project requires me to clear cache for some reason, but I try to google it for 1 day and follow the guide but the cache still there.

Can somebody help me to delete cache in MVC ASP.NET?

Here my code situation:

Controller: I use it to cache user's _searchcontent

[OutputCache(Duration = 900, Location = System.Web.UI.OutputCacheLocation.Server, VaryByParam = "_searchContent")]
[HttpGet]
public JsonResult searchJS(string _searchContent)
{
  var _userListfiltered = (from m in databaseContext.Table_Accounts
                           where m.userID.Contains(_searchContent)
                           select m);
  return new JsonResult {  
                           Data = _userListfiltered.ToArray() ,
                           JsonRequestBehavior = JsonRequestBehavior.AllowGet
                        };
}

Delete cache function (in the same controller)

public ActionResult deleteCache()
{
    var path = @Url.Action("searchJS", "Admin", new
    {
        _searchContent = "admin"
    });

    //HttpResponse.RemoveOutputCacheItem(path);
    Response.RemoveOutputCacheItem(path);
    return RedirectToAction("Adminpage","Admin");
}

I try to search admin then run the deleteCache function then I reenter the word admin and the cache still not be deleted, and I don't know why.

Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120
  • 1
    did you try http://stackoverflow.com/questions/12776466/how-to-clear-cache-in-specified-controller-in-asp-mvc or http://stackoverflow.com/questions/11585/clearing-page-cache-in-asp-net – man_luck Jul 16 '15 at 07:39
  • @man_luck I have try but it's doesn't look work, I think this solution is use for disable cache of a specific actionresult – Nguyen Le Minh Jul 16 '15 at 08:01

0 Answers0