Пример #1
0
        public void Init(HttpApplication app)
        {
            if (!initialized)
            {
                lock (typeof(RedisSessionStateModule)) {
                    if (!initialized)
                    {
                        redisConfig = RedisSessionStateConfiguration.GetConfiguration();

                        // Add event handlers.
                        app.AcquireRequestState += new EventHandler(this.OnAcquireRequestState);
                        app.ReleaseRequestState += new EventHandler(this.OnReleaseRequestState);
                        app.EndRequest          += new EventHandler(this.OnEndRequest);

                        // Create a SessionIDManager.
                        sessionIDManager = new SessionIDManager();
                        sessionIDManager.Initialize();

                        redisConnection = new RedisConnection(redisConfig.Host, redisConfig.Port);

                        initialized = true;
                    }
                }
            }
        }
 public override void Initialize(string name, NameValueCollection config)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         name = "AspNetSession";
     }
     base.Initialize(name, config);
     this.redisConfig = RedisSessionStateConfiguration.GetConfiguration();
     this.lockHashKey = name + ":LockedSessions";
 }
        public void Init(HttpApplication app)
        {
            if (this.initialized)
            {
                return;
            }
            lock (typeof(RedisSessionStateModule))
            {
                if (this.initialized)
                {
                    return;
                }
                this.redisConfig         = RedisSessionStateConfiguration.GetConfiguration();
                app.AcquireRequestState += new EventHandler(this.OnAcquireRequestState);
                app.ReleaseRequestState += new EventHandler(this.OnReleaseRequestState);
                app.EndRequest          += new EventHandler(this.OnEndRequest);

                SessionStateSection sessionState = ConfigurationManager.GetSection("system.web/sessionState") as SessionStateSection;

                string            sessionIdManagerType = sessionState?.SessionIDManagerType;
                ISessionIDManager sessionIdManager;

                if (string.IsNullOrEmpty(sessionIdManagerType))
                {
                    sessionIdManager = new SessionIDManager();
                }
                else
                {
                    Type type = Type.GetType(sessionIdManagerType, false);
                    if (type != null)
                    {
                        sessionIdManager = Activator.CreateInstance(type) as ISessionIDManager ?? new SessionIDManager();
                    }
                    else
                    {
                        sessionIdManager = new SessionIDManager();
                    }
                }

                this.sessionIDManager = sessionIdManager;
                this.sessionIDManager.Initialize();
                this.redisConnection = new RedisConnection(this.redisConfig.Host, this.redisConfig.Port, -1, (string)null, int.MaxValue, false, 10000);
                this.initialized     = true;
            }
        }