asp.net-mvc-3 – outputcache mvc3只注销了用户缓存
发布时间:2020-10-19 17:44:18 所属栏目: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下经典数据库记录分页代码
- 是否可以使用ASP.NET ScriptManager来使用Windows FIPS安全
- asp.net – Isapi过滤器无法在IIS 7上运行(在IIS 6上运行)
- ASP.NET性能优化之局部缓存分析
- 用ADO.NET处理层次数据
- asp.net-mvc-4 – 如何在Kendo UI Grid中扩展页面加载时的所
- asp.net-mvc – SelectListItem中的Selected属性永远不会起
- 各大输入法分类词库内部格式的简单比较
- ASP.NET:WebResource.axd调用404错误:如何知道哪个程序集
- asp.net-mvc – Url.RouteUrl返回null
推荐文章
站长推荐
- asp.net – 如何设置显示内联的Div元素的固定宽度
- asp.net – Dropzone没有绑定到模型
- asp.net – 在我的网站中添加HttpModule时出现“
- MVC学习二:基础语法
- asp.net-mvc – Mvc 3 Razor:使用部分部分视图?
- asp.net-mvc – asp.net mvc – string或int的路
- 如何将数组从Asp.net服务器端传递到客户端的Java
- asp.net-core – 如何在Visual Studio 2015 RC中
- asp.net-mvc-3 – 是否可能获得一个ASP.NET MVC
- asp.net – IIS Web Garden中的Singleton对象
热点阅读