如何在 asp.net mvc 2 的辅助方法中应用缓存
我的应用程序中有一个辅助方法,并且我已对其应用了输出缓存,
[OutputCache(Duration = 3600, VaryByParam = "DetailsId")]
public static Dictionary<string, object> GetData(int DetailsId)
{
}
但在每次请求时都会调用此函数。
我想知道我可以在 Helper 方法上应用输出缓存吗?如果是的话怎么办?
I have a helper method in my application and i have applied output caching on it
[OutputCache(Duration = 3600, VaryByParam = "DetailsId")]
public static Dictionary<string, object> GetData(int DetailsId)
{
}
but on every request this function is called.
I want to know can i apply Output Cache on Helper method? If yes then how ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的输出缓存属性需要位于 ActionResult 上,而不是位于静态或非静态方法上。
例如,
简而言之,您不能使用此级别的 OutputCache 属性,请使用与缓存对象类似的内容:
Your Output Cache attribute needs to be on an ActionResult not on a static or non static method.
For instance
In short you cannot use the OutputCache attribute this level use something along the lines of the Cache Object: