public override void OnActionExecuting(ActionExecutingContext filterContext) { HttpSessionStateBase session = filterContext.HttpContext.Session; var user = session["users"]; if (((user == null) && (!session.IsNewSession)) || (session.IsNewSession)) { session.RemoveAll(); session.Clear(); session.Abandon(); filterContext.Result = new RedirectToRouteResult( new RouteValueDictionary { { "Controller", "Login" }, { "Action", "Index" } }); } else { System.Int32 timeOut = System.Web.HttpContext.Current.Session.Timeout; if (timeOut < 5) { session.Timeout = timeOut + 10; } } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { HttpSessionStateBase session = filterContext.HttpContext.Session; Services.User user = (Services.User)session[Constants.SESSION_USER]; if (user != null) { return; } String urlFrom = String.Empty; UrlHelper url; //send them off to the login page url = new UrlHelper(filterContext.RequestContext); urlFrom = filterContext.Controller.ControllerContext.RequestContext.HttpContext.Request.RawUrl; if (!String.IsNullOrEmpty(urlFrom)) { urlFrom = String.Format("?{0}", urlFrom); } var loginUrl = url.Content(String.Format("~/LogIn{0}", urlFrom)); session.RemoveAll(); session.Clear(); session.Abandon(); filterContext.HttpContext.Response.StatusCode = 403; filterContext.HttpContext.Response.Redirect(loginUrl, false); filterContext.Result = new EmptyResult(); }
public void Abandon(string openId) { _log.Write("SessionPool.Abandon", "OpenId:" + openId, TraceEventType.Verbose); if (String.IsNullOrEmpty(openId)) { return; } HttpSessionStateBase session = _sessionTable[openId] as HttpSessionStateBase; if (session == null) { return; } session.Clear(); session.Abandon(); lock (_lockObj) { _sessionTable.Remove(openId); } _log.Write("SessionPool.Abandon Done", "OpenId:" + openId, TraceEventType.Verbose); }
/// <summary> /// Sets the value in session, clearing any previous values /// </summary> public static void Set(this HttpSessionStateBase session, String valueName, Object value) { if (null == session) { return; } session.Clear(valueName); session[valueName] = value; }
public static void AbandonSession(HttpSessionStateBase session) { try { logger.Info(string.Format("Clearing session {0}.", session.SessionID)); ConfigurationHelper config = new ConfigurationHelper(); if (!config.IsMockUserIdentity) { session.Clear(); session.Abandon(); } } catch (Exception) { session.Clear(); session.Abandon(); } }
public static void ClearSessionData(HttpSessionStateBase Session) { string returnURL = Session["ReturnURL"] != null ? Session["ReturnURL"].ToString() : string.Empty; Session.Clear(); if (!string.IsNullOrEmpty(returnURL)) { Session["ReturnURL"] = returnURL; } }
//登出 清除登录信息 public bool LoginOut(HttpResponseBase response, HttpSessionStateBase session) { HttpCookie userCookies = response.Cookies["User"]; if (userCookies != null) { userCookies.Expires = DateTime.Now.AddDays(-1); response.Cookies.Add(userCookies); } session.Clear(); return(true); }
/// <summary> /// Clear session /// </summary> /// <param name="session"> /// The current <see cref="HttpSessionState"/> /// </param> public static void ResetSession(HttpSessionStateBase session) { if (session != null) { if (SessionQueryExistsAndIsValid(session)) { GetSessionQuery(session).Reset(); GetSessionQuery(session).ResetDsds(); } session.Clear(); } }
public static void TerminateSession(HttpSessionStateBase session, string returnUrl) { try { logger.Info(string.Format("Termintating session {0}.", session.SessionID)); ConfigurationHelper config = new ConfigurationHelper(); if (!config.IsMockUserIdentity) { session.Clear(); } session["Terminated"] = true; session["ReturnUrl"] = returnUrl; } catch (Exception) { session.Clear(); session["Terminated"] = true; session["ReturnUrl"] = returnUrl; } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { HttpSessionStateBase session = filterContext.HttpContext.Session; var user = session["Usr_ID"]; if (user == null) { //send them off to the login page var url = new UrlHelper(filterContext.RequestContext); var loginUrl = filterContext.RouteData.Values.ContainsValue("Admin") ? url.Content("~/Admin/Login") : url.Content("~/Home/Index"); session.RemoveAll(); session.Clear(); session.Abandon(); filterContext.HttpContext.Response.Redirect(loginUrl, true); } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { HttpSessionStateBase session = filterContext.HttpContext.Session; var user = session["User"]; if (((user == null) && (!session.IsNewSession)) || (session.IsNewSession)) { //send them off to the login page var url = new UrlHelper(filterContext.RequestContext); var loginUrl = url.Content("~/Account/LogIn"); session.RemoveAll(); session.Clear(); session.Abandon(); filterContext.HttpContext.Response.Redirect(loginUrl, true); } }
public ActionResult LogOut() { HttpSessionStateBase session = HttpContext.Session; //filterContext.HttpContext.Session; if (session != null) { session.RemoveAll(); session.Clear(); session.Abandon(); Session["IsLogged"] = false; LoginInformation.UserInformation = null; LoginInformation.PermittedMenues = null; } return(Json(new { result = "Redirect", url = Url.Action("Index", "Home") })); }
/// <summary> /// Clears the user session, clears the forms auth ticket, expires the forms auth cookie. /// </summary> /// <param name="session">HttpSessionStateBase</param> /// <param name="response">HttpResponseBase</param> public static void Logout(HttpSessionStateBase session, HttpResponseBase response, HttpContextBase context) { // First clean the authentication ticket like always FormsAuthentication.SignOut(); // Second we clear the principal to ensure the user does not retain any authentication context.User = new GenericPrincipal(new GenericIdentity(string.Empty), null); session.Clear(); HttpContext.Current.Session.RemoveAll(); //// Last we clear authentication cookie. //HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, string.Empty); //cookie.Expires = DateTime.Now.AddYears(-1); //response.Cookies.Add(cookie); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { HttpSessionStateBase session = filterContext.HttpContext.Session; var user = session["CurrentUserName"]; if (filterContext.ActionDescriptor.GetCustomAttributes(typeof(DisableUserSessionAttribute), false).Any()) { return; } else if (((user == null) && (!session.IsNewSession)) || (session.IsNewSession)) { //send them off to the login page var url = new UrlHelper(filterContext.RequestContext); var loginUrl = url.Content("~/User/LogIn"); session.RemoveAll(); session.Clear(); session.Abandon(); filterContext.HttpContext.Response.Redirect(loginUrl, true); } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext != null) { HttpSessionStateBase objHttpSessionStateBase = filterContext.HttpContext.Session; var userSession = objHttpSessionStateBase["userObject"]; if (((userSession == null) && (!objHttpSessionStateBase.IsNewSession)) || (objHttpSessionStateBase.IsNewSession)) { objHttpSessionStateBase.RemoveAll(); objHttpSessionStateBase.Clear(); objHttpSessionStateBase.Abandon(); if (filterContext.HttpContext.Request.IsAjaxRequest()) { filterContext.HttpContext.Response.StatusCode = 403; filterContext.Result = new JsonResult { Data = "LogOut" }; } } } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { //do not execute the filter logic for Login/Index if (filterContext.RouteData.GetRequiredString("controller").Equals("LogIn", StringComparison.CurrentCultureIgnoreCase) && filterContext.RouteData.GetRequiredString("action").Equals("Index", StringComparison.CurrentCultureIgnoreCase)) { return; } HttpSessionStateBase session = filterContext.HttpContext.Session; var user = session["User"]; if (((user == null) && (!session.IsNewSession)) || (session.IsNewSession)) { session.RemoveAll(); session.Clear(); session.Abandon(); filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Login" }, { "action", "Index" } }); } base.OnActionExecuting(filterContext); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { HttpSessionStateBase session = filterContext.HttpContext.Session; if ((CheckSessionAlive == null) || (CheckSessionAlive(session))) { return; } var url = new UrlHelper(filterContext.RequestContext); var loginUrl = url.Content(LoginUrl); if (session != null) { session.RemoveAll(); session.Clear(); session.Abandon(); } filterContext.HttpContext.Response.StatusCode = 403; filterContext.HttpContext.Response.Redirect(loginUrl, true); filterContext.Result = new EmptyResult(); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { HttpSessionStateBase session = filterContext.HttpContext.Session; //var user = session["BrokerOfLoggedInUser"]; if ((session["LoggedInUser"] == null)) { if (GetUserLoggedIn(HttpContext.Current.User.Identity.GetUserId()) == 1) { //RestaurantEntities rce = new RestaurantEntities(); //tblRestaurantUser ru = new tblRestaurantUser(); ////brokerUserFactory = new BrokerUserFactory(); ////decimal membership_id = SessionManger.BrokerOfLoggedInUser(Session).membership_id; //string user_id = HttpContext.Current.User.Identity.GetUserId(); //int RestaurentId = Convert.ToInt32(session["RestaurantId"]); //ru.is_loggedIn = 0; //ru.UserId = user_id; //ru.Restaurant_id = RestaurentId; //rce.tblRestaurantUsers.Attach(ru); //var entry = rce.Entry(ru); //entry.State = EntityState.Modified; //rce.SaveChanges(); filterContext.HttpContext.GetOwinContext().Authentication.SignOut(); session.RemoveAll(); session.Clear(); session.Abandon(); } //send them off to the login page var url = new UrlHelper(filterContext.RequestContext); var loginUrl = url.Content("~/Account/Login"); filterContext.Result = new RedirectResult(loginUrl); return; } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (!NotVerifyMethod) { HttpSessionStateBase session = filterContext.HttpContext.Session; var user = session[Constantes.GrupoLocalizacion.UsuarioSesionId]; if (user == null) { session.RemoveAll(); session.Clear(); session.Abandon(); String vAccion = HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString(); if (filterContext.HttpContext.Request.IsAjaxRequest()) { if (vAccion != "_Session_Terminada") { filterContext.Result = new RedirectToRouteResult( new RouteValueDictionary { { "controller", "Sistema" }, { "action", "_Session_Terminada" } } ); } } else { filterContext.Result = new RedirectToRouteResult( new RouteValueDictionary { { "controller", "Sistema" }, { "action", "Login" }, { "SessionExpired", "True" } } ); } } } base.OnActionExecuting(filterContext); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { string loginUrl = System.Configuration.ConfigurationManager.AppSettings.Get("loginUrl"); logger.Info("FGL OnActionExecuting"); try { HttpSessionStateBase session1 = filterContext.HttpContext.Session; logger.Info("get session test:" + session1.SessionID.ToString()); HttpSessionStateBase session = filterContext.HttpContext.Session; if (filterContext.HttpContext.Session["UserID"] == null) { logger.Info("filterContext.HttpContext.Session[UserID] null"); var url = new UrlHelper(filterContext.RequestContext); //var loginUrl = url.Content("~/Account/Login"); session.RemoveAll(); session.Clear(); session.Abandon(); filterContext.HttpContext.Response.Redirect(loginUrl, true); } else { logger.Info("filterContext.HttpContext.Session[UserID] not null"); } } catch (Exception e) { logger.Info(e.ToString()); var url = new UrlHelper(filterContext.RequestContext); //var loginUrl = url.Content("~/Account/Login"); filterContext.HttpContext.Response.Redirect(loginUrl, true); } }
public void ClearStorage() { _session.Clear(); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { // Do not execute the filter logic for User/Login if (filterContext.RouteData.GetRequiredString("controller").Equals("User", StringComparison.CurrentCultureIgnoreCase) && filterContext.RouteData.GetRequiredString("action").Equals("Login", StringComparison.CurrentCultureIgnoreCase)) { if (!filterContext.HttpContext.Request.IsAjaxRequest()) { return; } else { filterContext.Result = new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { Valid = false, RedirectUrl = FormsAuthentication.LoginUrl } }; } } HttpSessionStateBase session = filterContext.HttpContext.Session; var username = HttpContext.Current.User != null ? HttpContext.Current.User.Identity.Name : string.Empty; _userFacade = new UserFacade(); _userFacade.CheckExceededMaxConcurrent(username, session); if (!filterContext.HttpContext.Request.IsAjaxRequest()) { if (((session["sessionid"] == null) && (!session.IsNewSession)) || (session.IsNewSession)) { // Clear cache var cacheKey = string.Format(CultureInfo.InvariantCulture, "{0}_user_info", username); if (HttpRuntime.Cache[cacheKey] != null) { HttpRuntime.Cache.Remove(cacheKey); } session.RemoveAll(); session.Clear(); session.Abandon(); string returnUrl = GetReturnUri(filterContext); RouteValueDictionary dict = new RouteValueDictionary(); dict.Add("controller", "User"); dict.Add("action", "Login"); if (!string.IsNullOrWhiteSpace(returnUrl)) { dict.Add("returnUrl", returnUrl); } filterContext.Result = new RedirectToRouteResult(dict); } base.OnActionExecuting(filterContext); } else { if (((session["sessionid"] == null) && (!session.IsNewSession)) || (session.IsNewSession)) { // Clear cache var cacheKey = string.Format(CultureInfo.InvariantCulture, "{0}_user_info", username); if (HttpRuntime.Cache[cacheKey] != null) { HttpRuntime.Cache.Remove(cacheKey); } session.RemoveAll(); session.Clear(); session.Abandon(); filterContext.Result = new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { Valid = false, RedirectUrl = FormsAuthentication.LoginUrl } }; } } }
public void Clear() { _httpSession.Clear(); }
public static void RemoveAllFromSession(this HttpSessionStateBase session) { session.RemoveAll(); session.Clear(); }
public void CleanSession() { _session.Clear(); }
static public void ClearSession(HttpSessionStateBase session) { session.Clear(); }