protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); object[] objAllowedAnonymousArray = filterContext.ActionDescriptor.GetCustomAttributes(typeof(AllowedAnonymous), false); if (objAllowedAnonymousArray.Length > 0) { return; } UserContext = SessionContainer.GetUserContext(HttpContext) as ShellUserContext; if (UserContext == null) { //返回登录超时的消息 } }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); object[] objAllowedAnonymousArray = filterContext.ActionDescriptor.GetCustomAttributes(typeof(AllowedAnonymous), false); if (objAllowedAnonymousArray.Length > 0) { return; } UserContext = SessionContainer.GetUserContext(HttpContext) as ShellUserContext; if (UserContext == null) { //重定向到登录页面 filterContext.Result = new RedirectResult("/Home/Login"); return; } ViewBag.UserContext = UserContext; }
public static bool Verify(string key, HttpContext httpContext) { ShellUserContext userContext = (ShellUserContext)SessionContainer.GetUserContext(httpContext); return(userContext.AuthorizationKeyVerify(key)); }