asp.net-mvc-3 – outputcache mvc3只注销了用户缓存
发布时间:2020-10-19 17:17:26 所属栏目:asp.Net 来源:互联网
导读:有没有办法使用OutputCache属性来缓存仅注销用户的结果并重新评估登录用户示例: 我想要什么 [OutputCache(onlycacheanon = true)]public ActionResult GetPhoto(id){ var photo = getPhoto(id); if(!photo.issecured){ return photo... }
有没有办法使用OutputCache属性来缓存仅注销用户的结果并重新评估登录用户示例: 我想要什么 [OutputCache(onlycacheanon = true)] public ActionResult GetPhoto(id){ var photo = getPhoto(id); if(!photo.issecured){ return photo... } return getPhotoOnlyIfCurrentUserHasAccess(id); //otherwise return default photo so please don't cache me } 解决方法您可以在[OutputCache]中使用VaryByCustom属性.然后覆盖HttpApplication.GetVaryByCustomString并检查HttpContext.Current.User.IsAuthenticated. >如果未经过身份验证,则返回“NotAuthed”或类似内容(激活缓存)> Guid.NewGuid().ToString()使缓存无效 (编辑:鄂州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc-3 – “区域”文件夹中的样式,脚本和图像
- RSS2.0中文规范详解及示例
- asp.net – 在为app_offline.htm提供特定URL时,将http状态5
- asp.net-mvc – 使用AWS .NET SDK进行SNS订阅确认示例
- asp.net – Isapi过滤器无法在IIS 7上运行(在IIS 6上运行)
- 介绍几种 ADO.net 中的数据库连接方式
- asp.net-mvc – 为什么我在带有godaddy服务器的MVC3应用程序
- asp.net操作xml增删改示例分享
- asp.net-mvc – 在ASP.NET MVC中添加服务引用4
- asp.net-mvc-2 – 使用’class(或其他保留关键字)作为匿名类
推荐文章
站长推荐
热点阅读