/// <summary> /// 在过程请求授权时调用。 /// </summary> /// <param name="filterContext">筛选器上下文,它封装有关使用 <see cref="T:System.Web.Mvc.AuthorizeAttribute" /> 的信息。</param> /// 创建者:孟祺宙 /// 创建日期:2014/9/22 17:23 /// 修改者: /// 修改时间: /// ---------------------------------------------------------------------------------------- public override void OnAuthorization(AuthorizationContext filterContext) { if (!IsLogin(filterContext.RequestContext.HttpContext)) { YG.SC.OpenShop.Authentication.FormAuthenticationService fom = new YG.SC.OpenShop.Authentication.FormAuthenticationService(); fom.SignOut(); filterContext.Result = new RedirectResult("~/Login/Index", true); } }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { if (UserId > 0) { TempData["LayoutUserName"] = UserName; TempData["LayoutUserId"] = UserId; } else { YG.SC.OpenShop.Authentication.FormAuthenticationService fom = new YG.SC.OpenShop.Authentication.FormAuthenticationService(); fom.SignOut(); filterContext.Result = new RedirectResult("~/Login/Index"); } base.OnActionExecuting(filterContext); }