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.