public override SessionStateStoreData GetItem(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId,
                                                      out SessionStateActions actions)
        {
            var returnValue = _store.GetItem(context, id, out locked, out lockAge, out lockId, out actions);

            if (returnValue == null && lockId != null)
            {
                _store.ReleaseItemExclusive(context, id, lockId);
                returnValue = _store.GetItem(context, id, out locked, out lockAge, out lockId, out actions);
            }

            return(returnValue);
        }
예제 #2
0
        private string RegenrateSessionId()
        {
            var         manager = new SessionIDManager();
            HttpContext context = System.Web.HttpContext.Current;
            string      oldId = manager.GetSessionID(context);
            string      newId = manager.CreateSessionID(context);
            bool        isAdd = false, isRedir = false;

            manager.SaveSessionID(context, newId, out isRedir, out isAdd);
            var ctx                   = (HttpApplication)System.Web.HttpContext.Current.ApplicationInstance;
            HttpModuleCollection mods = ctx.Modules;
            var ssm                   = (SessionStateModule)mods.Get("Session");

            FieldInfo[] fields = ssm.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            SessionStateStoreProviderBase store = null;
            FieldInfo rqIdField = null, rqLockIdField = null, rqStateNotFoundField = null;

            foreach (FieldInfo field in fields)
            {
                if (field.Name.Equals("_store"))
                {
                    store = (SessionStateStoreProviderBase)field.GetValue(ssm);
                }
                if (field.Name.Equals("_rqId"))
                {
                    rqIdField = field;
                }
                if (field.Name.Equals("_rqLockId"))
                {
                    rqLockIdField = field;
                }
                if (field.Name.Equals("_rqSessionStateNotFound"))
                {
                    rqStateNotFoundField = field;
                }
            }
            if (rqLockIdField != null)
            {
                object lockId = rqLockIdField.GetValue(ssm);
                if ((lockId != null) && (oldId != null))
                {
                    if (store != null)
                    {
                        store.ReleaseItemExclusive(context, oldId, lockId);
                    }
                }
            }
            if (rqStateNotFoundField != null)
            {
                rqStateNotFoundField.SetValue(ssm, true);
            }
            if (rqIdField != null)
            {
                rqIdField.SetValue(ssm, newId);
            }
            return(newId);
        }
예제 #3
0
        public ActionResult Login(int?id)
        {
            //Session.Abandon();
            SessionIDManager manager = new SessionIDManager();

            manager.RemoveSessionID(System.Web.HttpContext.Current);
            var oldId        = manager.GetSessionID(System.Web.HttpContext.Current);
            var newId        = manager.CreateSessionID(System.Web.HttpContext.Current);
            var isRedirected = true;
            var isAdded      = true;

            manager.SaveSessionID(System.Web.HttpContext.Current, newId, out isRedirected, out isAdded);
            System.Web.HttpContext.Current.Session["sessionid"] = newId;
            HttpApplication      ctx  = (HttpApplication)System.Web.HttpContext.Current.ApplicationInstance;
            HttpModuleCollection mods = ctx.Modules;

            System.Web.SessionState.SessionStateModule ssm = (SessionStateModule)mods.Get("Session");
            System.Reflection.FieldInfo[] fields           = ssm.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            SessionStateStoreProviderBase store            = null;

            System.Reflection.FieldInfo rqIdField = null, rqLockIdField = null, rqStateNotFoundField = null;
            foreach (System.Reflection.FieldInfo field in fields)
            {
                if (field.Name.Equals("_store"))
                {
                    store = (SessionStateStoreProviderBase)field.GetValue(ssm);
                }
                if (field.Name.Equals("_rqId"))
                {
                    rqIdField = field;
                }
                if (field.Name.Equals("_rqLockId"))
                {
                    rqLockIdField = field;
                }
                if (field.Name.Equals("_rqSessionStateNotFound"))
                {
                    rqStateNotFoundField = field;
                }
            }
            object lockId = rqLockIdField.GetValue(ssm);

            if ((lockId != null) && (oldId != null))
            {
                store.ReleaseItemExclusive(System.Web.HttpContext.Current, oldId, lockId);
            }
            rqStateNotFoundField.SetValue(ssm, true);
            rqIdField.SetValue(ssm, newId);

            ViewBag.CompanyID     = id;
            ViewBag.Message       = id.HasValue ? "" : "缺少公司标识";
            ViewBag.ThirdLoginUrl = string.Format("{0}?client_id={1}&redirect_uri={2}&state={3}&response_type=code", authorizeUrl, clinetId, redirectUri, state);
            return(View());
        }
예제 #4
0
        public static void RegenrateSessionId()
        {
            Authorization.AuthoCookie.RegenerateAuthoCookie();
            SessionIDManager manager = new SessionIDManager();
            string           oldId = manager.GetSessionID(HttpContext.Current);
            string           newId = manager.CreateSessionID(HttpContext.Current);
            bool             isAdd = false, isRedir = false;

            manager.SaveSessionID(HttpContext.Current, newId, out isRedir, out isAdd);
            HttpApplication      ctx  = (HttpApplication)HttpContext.Current.ApplicationInstance;
            HttpModuleCollection mods = ctx.Modules;

            System.Web.SessionState.SessionStateModule ssm = (SessionStateModule)mods.Get("Session");
            System.Reflection.FieldInfo[] fields           = ssm.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            SessionStateStoreProviderBase store            = null;

            System.Reflection.FieldInfo rqIdField = null, rqLockIdField = null, rqStateNotFoundField = null;
            foreach (System.Reflection.FieldInfo field in fields)
            {
                if (field.Name.Equals("_store"))
                {
                    store = (SessionStateStoreProviderBase)field.GetValue(ssm);
                }
                if (field.Name.Equals("_rqId"))
                {
                    rqIdField = field;
                }
                if (field.Name.Equals("_rqLockId"))
                {
                    rqLockIdField = field;
                }
                if (field.Name.Equals("_rqSessionStateNotFound"))
                {
                    rqStateNotFoundField = field;
                }
            }
            object lockId = rqLockIdField.GetValue(ssm);

            if ((lockId != null) && (oldId != null))
            {
                store.ReleaseItemExclusive(HttpContext.Current, oldId, lockId);
            }
            rqStateNotFoundField.SetValue(ssm, true);
            rqIdField.SetValue(ssm, newId);
        }