[英]State management with Session and Cache in Asp.NET (MVC)
Creating a Web App using ASP.NET MVC3, essential framework includes NHibernate (Fluent), Ninject, Razor, Automapper, Jquery, Rhino-Security.使用ASP.NET MVC3创建一个Web App,基本框架包括NHibernate(Fluent),Ninject,Razor,Automapper,Jquery,Rhino-Security。
Need to decide upon State Management Stratety (Session and Cache level).需要决定 State 管理策略(会话和缓存级别)。 I have heard of following caching types,
我听说过以下缓存类型,
Considering a general scenario, I want to understand State Management policy to be used during a request,考虑到一般情况,我想了解 State 请求期间要使用的管理策略,
LOGIN登录
PAGE ACCESS页面访问
I see i have been too verbose.我知道我太啰嗦了。 In fact i do have more Questions, but let me see first if smbdy really bothers to read this much crap here
事实上,我确实有更多问题,但让我先看看 smbdy 是否真的费心在这里阅读这么多废话
Regarding User Permissions, given they are the same for each User Group, I would store them in Cache like this:关于用户权限,鉴于它们对于每个用户组都是相同的,我会像这样将它们存储在缓存中:
if (System.Web.HttpContext.Current.Cache["UserGroup_1_Permissions"] == null)
{
_Permissions = DAL.getPermissions("UserGroup1") as List<Permissions>;
System.Web.HttpContext.Current.Cache["UserGroup_1_Permissions"] = _Permissions;
}
else
{
_Permissions = System.Web.HttpContext.Current.Cache["UserGroup_1_Permissions"] as List<Permissions>;
}
This way, you would retrieve them from DB only first time, as it will get stored in HttpContext.Current.Cache.这样,您只需第一次从数据库中检索它们,因为它将存储在 HttpContext.Current.Cache 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.