当前位置: 首页>>代码示例>>C#>>正文


C# CacheManager.Refresh方法代码示例

本文整理汇总了C#中CacheManager.Refresh方法的典型用法代码示例。如果您正苦于以下问题:C# CacheManager.Refresh方法的具体用法?C# CacheManager.Refresh怎么用?C# CacheManager.Refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CacheManager的用法示例。


在下文中一共展示了CacheManager.Refresh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoginByRole

        public ActionResult LoginByRole(Int64 RefUserId, Int64 RefRoleId)
        {
            RefUser user = AccountService.GetUserById(RefUserId);

            if (user != null && AccountService.GetUserRole(user.RefUserId).Any(w => w.RefRoleId == RefRoleId))
            {
                CustomPrincipalSerializeModel serializeModel = new CustomPrincipalSerializeModel()
                {
                    FullName = user.RefEmp.EmpName,
                    UserId = user.RefUserId,
                    UserName = user.UserName,
                    EmpId = user.RefEmpId,
                    RoleId = RefRoleId,
                    RoleCode = user.RefRoles.Where(w => w.RefRoleId == RefRoleId).First().RoleCode,
                    RoleName = user.RefRoles.Where(w => w.RefRoleId == RefRoleId).First().RoleName,
                    // bypass culture profile for user - testing purpose
                    Culture = "id-ID"

                };

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                string userData = serializer.Serialize(serializeModel);

                HttpCookie cookie = Request.Cookies["_culture"];
                if (cookie != null)
                {
                    cookie.Value = serializeModel.Culture; ;   // update culture cookie value based on user default profile
                }
                else
                {
                    cookie = new HttpCookie("_culture");
                    cookie.Value = serializeModel.Culture;
                    cookie.Expires = DateTime.Now.AddYears(1);
                }

                Response.Cookies.Add(cookie);

                SecurityHelper.SetAuthCookieMain(user.UserName, userData, true, null);

                // refresh the cache for testing purpose
                // in reality, refresh when role menu has changed!!! ( ex: at Role menu edit )
                var menuCache = new CacheManager<String>("menu." + serializeModel.RoleCode.ToLower());
                menuCache.Refresh();

                GetMenuTreeByRole(serializeModel.RoleId, serializeModel.RoleCode);

                return RedirectToAction("Index", "Home");

            }

            return RedirectToAction("Login");
        }
开发者ID:sbudihar,项目名称:SIRIUSrepo,代码行数:52,代码来源:AccountController.cs


注:本文中的CacheManager.Refresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。