是否可以在mvc JsonResult控制器方法上使用OutputCache?

时间:2010-01-15 20:29:56

标签: asp.net-mvc json outputcache

我正在尝试这样做,并导致contentlen 0的结果

看起来像:

[OutputCache(Duration = 36000)]
public JsonResult GetFileClasses() 
{
   return this.Json(TopicConfig.FileExtensionsSettings.List)
}

有什么想法吗?

1 个答案:

答案 0 :(得分:15)

OutputCacheAttribute中,您还必须指定VaryByParam参数。否则,您将在结果处理System.Web.HttpException: The directive or the configuration settings profile must specify the 'varyByParam' attribute.上获得此异常 您可以尝试添加此参数,看看它是否有效。