本文整理汇总了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");
}