コード例 #1
0
        public static void HttpToSignalR(MigrateSession attribute, bool migrate = true)
        {
            string SessionIDCookieKey = InternalSessionKeys.SessionIDCookieKey;
            string MigrateBackFlagKey = InternalSessionKeys.MigrateBackFlagKey;

            HttpSessionState Session = HttpContext.Current.Session;

            if (Session == null)
            {
                throw new Exception("HttpSession doesn't exsist");
            }

            SignalRContext.SessionProvider.ClearSession(Session.SessionID);

            if (migrate)
            {
                for (int i = 0; i < Session.Keys.Count; i++)
                {
                    string key = Session.Keys[i];
                    SignalRContext.SessionProvider[Session.SessionID][key] = Session[key];
                }
            }
            SignalRContext.SessionProvider[Session.SessionID][MigrateBackFlagKey] = attribute.MigrateBack;


            // cookie cleenup
            HttpCookie requestCookie  = HttpContext.Current.Request.Cookies[SessionIDCookieKey];
            HttpCookie responseCookie = HttpContext.Current.Response.Cookies[SessionIDCookieKey];

            if (requestCookie != null)
            {
                HttpContext.Current.Request.Cookies.Remove(SessionIDCookieKey);
            }
            if (responseCookie != null)
            {
                HttpContext.Current.Response.Cookies.Remove(SessionIDCookieKey);
            }

            HttpCookie cookie = new HttpCookie(SessionIDCookieKey, Session.SessionID);

            cookie.Expires  = DateTime.MaxValue;
            cookie.HttpOnly = true;
            HttpContext.Current.Response.Cookies.Add(cookie);
        }
コード例 #2
0
        public static void HttpToSignalR(MigrateSession attribute, bool migrate = true)
        {
            string SessionIDCookieKey = InternalSessionKeys.SessionIDCookieKey;
            string MigrateBackFlagKey = InternalSessionKeys.MigrateBackFlagKey;

            HttpSessionState Session = HttpContext.Current.Session;
            if (Session == null)
            {
                throw new Exception("HttpSession doesn't exsist");
            }

            SignalRContext.SessionProvider.ClearSession(Session.SessionID);

            if (migrate)
            {
                for (int i = 0; i < Session.Keys.Count; i++)
                {
                    string key = Session.Keys[i];
                    SignalRContext.SessionProvider[Session.SessionID][key] = Session[key];
                }
            }
            SignalRContext.SessionProvider[Session.SessionID][MigrateBackFlagKey] = attribute.MigrateBack;


            // cookie cleenup
            HttpCookie requestCookie = HttpContext.Current.Request.Cookies[SessionIDCookieKey];
            HttpCookie responseCookie = HttpContext.Current.Response.Cookies[SessionIDCookieKey];

            if (requestCookie != null)
            {
                HttpContext.Current.Request.Cookies.Remove(SessionIDCookieKey);
            }
            if (responseCookie != null)
            {
                HttpContext.Current.Response.Cookies.Remove(SessionIDCookieKey);
            }

            HttpCookie cookie = new HttpCookie(SessionIDCookieKey, Session.SessionID);
            cookie.Expires = DateTime.MaxValue;
            cookie.HttpOnly = true;
            HttpContext.Current.Response.Cookies.Add(cookie);
        }
コード例 #3
0
 public static void Execute(bool migrateBack = false)
 {
     MigrateSession.HttpToSignalR(new MigrateSession(migrateBack));
 }