asp.net-mvc-3 – outputcache mvc3只注销了用户缓存
发布时间:2020-10-19 13:45:00 所属栏目: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 – MVC DB首先修复显示名称
- asp.net+js实现批量编码与解码的方法
- asp.net-core – 具有取消令牌的自定义AspCore中间件
- ASP.NET core Web中使用appsettings.json配置文件的方法
- dependency-injection – 从ILogger访问当前的HttpContext
- asp.net Gridview,1记录跨度两行
- asp.net-core – 构建asp.net核心错误
- asp.net-web-api2 – 在WebAPI2项目中加载System.IdentityM
- asp.net-mvc – 值不能为空或为空.参数名称:contentPath
- asp.net-mvc – 神秘的ASP.NET MVC Action高延迟问题?
推荐文章
站长推荐
热点阅读