Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用多个VaryByParam删除OutputCache_C#_Asp.net_Asp.net Mvc_Caching_Outputcache - Fatal编程技术网

C# 使用多个VaryByParam删除OutputCache

C# 使用多个VaryByParam删除OutputCache,c#,asp.net,asp.net-mvc,caching,outputcache,C#,Asp.net,Asp.net Mvc,Caching,Outputcache,我有这样一个动作: [OutputCache(Duration = 3600, Location = OutputCacheLocation.ServerAndClient, VaryByParam = "page;categor;searchString")] public virtual async Task<ActionResult> Index(int? category, int page = 1, string searchString = null)

我有这样一个动作:

    [OutputCache(Duration = 3600, Location = OutputCacheLocation.ServerAndClient, VaryByParam = "page;categor;searchString")]
    public virtual async Task<ActionResult> Index(int? category, int page = 1, string searchString = null)
但为此,我必须与我的数据库建立多个连接,并获取类别、页面,即使我以某种方式获取所有搜索字符串,这仍然会造成太多的麻烦

我的问题是,有没有更好的方法一次删除所有这些缓存

有没有更好的方法一次删除所有这些缓存

我不知道。但您可以删除特定控制器操作方法的缓存项,如下所示(假设控制器名称为
controller1
)。取材于


是的,我见过,但据我所知,没有这样的方法;是,一旦持续时间跳闸,它将被清除。
var urls = new List<string>();
foreach (var url in urls)
{
   HttpResponse.RemoveOutputCacheItem(url);
}
HttpResponse.RemoveOutputCacheItem(Url.Action("Index", "controller1", new { category = 1234  }));