【发布时间】:2010-09-24 13:24:01
【问题描述】:
我正在尝试像这样在 MVC2 中缓存控制器操作的输出:
[OutputCache(Duration = 600, VaryByParam = "id", Location=System.Web.UI.OutputCacheLocation.Server)]
public FileContentResult GetImage(int id) {
}
当用户为其图标上传新图像时,我使用以下行使缓存无效:
HttpResponse.RemoveOutputCacheItem("/MyPage/GetImage/" + u.UserID.ToString());
但这似乎不起作用,我不知道为什么
【问题讨论】:
-
您的代码看起来正确。你能验证
u.UserID.ToString()正在返回正确的 id 吗? -
是的,它肯定会返回正确的 id