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; } } } }
/// <summary> /// IHttpModule.Init /// </summary> /// <param name="app"></param> public void Init(HttpApplication app) { // Add event handlers. app.AcquireRequestState += OnAcquireRequestState; app.ReleaseRequestState += OnReleaseRequestState; app.EndRequest += OnEndRequest; // Create a SessionIDManager. sessionIdManager = new SessionIDManager(); sessionIdManager.Initialize(); // If not already initialized, initialize timer and configuration. if (!initialized) { lock (LockObject) { if (!initialized) { OnInit(); // Get the configuration section and set timeout and CookieMode values. Configuration cfg = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath); SessionStateSection config = (SessionStateSection)cfg.GetSection("system.web/sessionState"); Timeout = (int)config.Timeout.TotalMinutes; CookieMode = config.Cookieless; initialized = true; } } } }
private void InitModuleFromConfig(HttpApplication app, SessionStateSection config) { if (config.Mode == SessionStateMode.Off) { return; } app.AddOnAcquireRequestStateAsync(BeginAcquireState, EndAcquireState); app.AddOnReleaseRequestStateAsync(BeginOnReleaseState, EndOnReleaseState); app.AddOnEndRequestAsync(BeginOnEndRequest, EndOnEndRequest); if (config.Mode == SessionStateMode.Custom) { _store = InitCustomStore(config); } else if (config.Mode == SessionStateMode.InProc) { _store = new InProcSessionStateStoreAsync(); _store.Initialize(null, null); } else { throw new ConfigurationErrorsException(SR.Not_Support_SessionState_Mode); } _idManager = InitSessionIDManager(config); }
public AuthenticationService( IQuickspatchHttpContext httpContext, IClaimsManager claimsManager, IFormAuthenticationService formAuthenticationService, ISessionIDManager sessionIdManager, IDiagnosticService diagnosticService, IUserRepository userRepository , ISystemEventService systemEventService, IFranchiseeConfigurationRepository franchiseeConfigurationRepository) { HttpContext = httpContext; FormAuthenticationService = formAuthenticationService; ClaimsManager = claimsManager; SessionIdManager = sessionIdManager; _diagnosticService = diagnosticService; _userRepository = userRepository; _systemEventService = systemEventService; _franchiseeConfigurationRepository = franchiseeConfigurationRepository; }
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; } }
private void InitModuleFromConfig(HttpApplication app, SessionStateSection config) { if (config.Mode != SessionStateMode.Off) { app.AddOnAcquireRequestStateAsync(new BeginEventHandler(this.BeginAcquireState), new EndEventHandler(this.EndAcquireState)); app.ReleaseRequestState += new EventHandler(this.OnReleaseState); app.EndRequest += new EventHandler(this.OnEndRequest); this._partitionResolver = this.InitPartitionResolver(config); switch (config.Mode) { case SessionStateMode.InProc: if (HttpRuntime.UseIntegratedPipeline) { s_canSkipEndRequestCall = true; } this._store = new InProcSessionStateStore(); this._store.Initialize(null, null); break; case SessionStateMode.StateServer: if (HttpRuntime.UseIntegratedPipeline) { s_canSkipEndRequestCall = true; } this._store = new OutOfProcSessionStateStore(); ((OutOfProcSessionStateStore)this._store).Initialize(null, null, this._partitionResolver); break; case SessionStateMode.SQLServer: this._store = new SqlSessionStateStore(); ((SqlSessionStateStore)this._store).Initialize(null, null, this._partitionResolver); break; case SessionStateMode.Custom: this._store = this.InitCustomStore(config); break; } this._idManager = this.InitSessionIDManager(config); if (((config.Mode == SessionStateMode.InProc) || (config.Mode == SessionStateMode.StateServer)) && this._usingAspnetSessionIdManager) { this._ignoreImpersonation = true; } } }
// // IHttpModule.Init // public void Init(HttpApplication app) { // Add event handlers. app.AcquireRequestState += new EventHandler(this.OnAcquireRequestState); app.ReleaseRequestState += new EventHandler(this.OnReleaseRequestState); app.EndRequest += new EventHandler(this.OnEndRequest); // Create a SessionIDManager. pSessionIDManager = new SessionIDManager(); pSessionIDManager.Initialize(); // If not already initialized, initialize timer and configuration. if (!pInitialized) { lock (typeof(LockFreeSessionStateModule)) { if (!pInitialized) { // Create a Timer to invoke the ExpireCallback method based on // the pTimerSeconds value (e.g. every 10 seconds). pTimer = new Timer(new TimerCallback(this.ExpireCallback), null, 0, pTimerSeconds * 1000); // Get the configuration section and set timeout and CookieMode values. Configuration cfg = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath); pConfig = (SessionStateSection)cfg.GetSection("system.web/sessionState"); pTimeout = (int)pConfig.Timeout.TotalMinutes; pCookieMode = pConfig.Cookieless; pInitialized = true; } } } }
public void Init(HttpApplication app) { config = (SessionStateSection)WebConfigurationManager.GetSection("system.web/sessionState"); ProviderSettings settings; switch (config.Mode) { case SessionStateMode.Custom: settings = config.Providers [config.CustomProvider]; if (settings == null) { throw new HttpException(String.Format("Cannot find '{0}' provider.", config.CustomProvider)); } break; case SessionStateMode.Off: return; case SessionStateMode.InProc: settings = new ProviderSettings(null, typeof(SessionInProcHandler).AssemblyQualifiedName); break; case SessionStateMode.SQLServer: settings = new ProviderSettings(null, typeof(SessionSQLServerHandler).AssemblyQualifiedName); break; case SessionStateMode.StateServer: settings = new ProviderSettings(null, typeof(SessionStateServerHandler).AssemblyQualifiedName); break; default: throw new NotImplementedException(String.Format("The mode '{0}' is not implemented.", config.Mode)); } handler = (SessionStateStoreProviderBase)ProvidersHelper.InstantiateProvider(settings, typeof(SessionStateStoreProviderBase)); if (String.IsNullOrEmpty(config.SessionIDManagerType)) { idManager = new SessionIDManager(); } else { Type idManagerType = HttpApplication.LoadType(config.SessionIDManagerType, true); idManager = (ISessionIDManager)Activator.CreateInstance(idManagerType); } try { idManager.Initialize(); } catch (Exception ex) { throw new HttpException("Failed to initialize session ID manager.", ex); } supportsExpiration = handler.SetItemExpireCallback(OnSessionExpired); HttpRuntimeSection runtime = HttpRuntime.Section; executionTimeout = runtime.ExecutionTimeout; //executionTimeoutMS = executionTimeout.Milliseconds; this.app = app; app.BeginRequest += new EventHandler(OnBeginRequest); app.AcquireRequestState += new EventHandler(OnAcquireRequestState); app.ReleaseRequestState += new EventHandler(OnReleaseRequestState); app.EndRequest += new EventHandler(OnEndRequest); }
public void Init (HttpApplication app) { config = (SessionStateSection) WebConfigurationManager.GetSection ("system.web/sessionState"); ProviderSettings settings; switch (config.Mode) { case SessionStateMode.Custom: settings = config.Providers [config.CustomProvider]; if (settings == null) throw new HttpException (String.Format ("Cannot find '{0}' provider.", config.CustomProvider)); break; case SessionStateMode.Off: return; case SessionStateMode.InProc: settings = new ProviderSettings (null, typeof (SessionInProcHandler).AssemblyQualifiedName); break; case SessionStateMode.SQLServer: settings = new ProviderSettings (null, typeof (SessionSQLServerHandler).AssemblyQualifiedName); break; case SessionStateMode.StateServer: settings = new ProviderSettings (null, typeof (SessionStateServerHandler).AssemblyQualifiedName); break; default: throw new NotImplementedException (String.Format ("The mode '{0}' is not implemented.", config.Mode)); } handler = (SessionStateStoreProviderBase) ProvidersHelper.InstantiateProvider (settings, typeof (SessionStateStoreProviderBase)); if (String.IsNullOrEmpty(config.SessionIDManagerType)) { idManager = new SessionIDManager (); } else { Type idManagerType = HttpApplication.LoadType (config.SessionIDManagerType, true); idManager = (ISessionIDManager)Activator.CreateInstance (idManagerType); } try { idManager.Initialize (); } catch (Exception ex) { throw new HttpException ("Failed to initialize session ID manager.", ex); } supportsExpiration = handler.SetItemExpireCallback (OnSessionExpired); HttpRuntimeSection runtime = HttpRuntime.Section; executionTimeout = runtime.ExecutionTimeout; //executionTimeoutMS = executionTimeout.Milliseconds; this.app = app; app.BeginRequest += new EventHandler (OnBeginRequest); app.AcquireRequestState += new EventHandler (OnAcquireRequestState); app.ReleaseRequestState += new EventHandler (OnReleaseRequestState); app.EndRequest += new EventHandler (OnEndRequest); }
void InitModuleFromConfig(HttpApplication app, SessionStateSection config) { if (config.Mode == SessionStateMode.Off) { return; } app.AddOnAcquireRequestStateAsync( new BeginEventHandler(this.BeginAcquireState), new EndEventHandler(this.EndAcquireState)); app.ReleaseRequestState += new EventHandler(this.OnReleaseState); app.EndRequest += new EventHandler(this.OnEndRequest); _partitionResolver = InitPartitionResolver(config); switch (config.Mode) { case SessionStateMode.InProc: if (HttpRuntime.UseIntegratedPipeline) { s_canSkipEndRequestCall = true; } _store = new InProcSessionStateStore(); _store.Initialize(null, null); break; #if !FEATURE_PAL // FEATURE_PAL does not enable out of proc session state case SessionStateMode.StateServer: if (HttpRuntime.UseIntegratedPipeline) { s_canSkipEndRequestCall = true; } _store = new OutOfProcSessionStateStore(); ((OutOfProcSessionStateStore)_store).Initialize(null, null, _partitionResolver); break; case SessionStateMode.SQLServer: _store = new SqlSessionStateStore(); ((SqlSessionStateStore)_store).Initialize(null, null, _partitionResolver); #if DBG ((SqlSessionStateStore)_store).SetModule(this); #endif break; #else // !FEATURE_PAL case SessionStateMode.StateServer: throw new NotImplementedException("ROTORTODO"); break; case SessionStateMode.SQLServer: throw new NotImplementedException("ROTORTODO"); break; #endif // !FEATURE_PAL case SessionStateMode.Custom: _store = InitCustomStore(config); break; default: break; } // We depend on SessionIDManager to manage session id _idManager = InitSessionIDManager(config); if ((config.Mode == SessionStateMode.InProc || config.Mode == SessionStateMode.StateServer) && _usingAspnetSessionIdManager) { // If we're using InProc mode or StateServer mode, and also using our own session id module, // we know we don't care about impersonation in our all session state store read/write // and session id read/write. _ignoreImpersonation = true; } }
// For testing. internal DefaultTempDataUserProvider(string fallbackCookieName, ISessionIDManager sessionIdManager) { this.fallbackCookieName = fallbackCookieName; this.sessionIdManager = sessionIdManager; }
private void InitModuleFromConfig(HttpApplication app, SessionStateSection config) { if (config.Mode != SessionStateMode.Off) { app.AddOnAcquireRequestStateAsync(new BeginEventHandler(this.BeginAcquireState), new EndEventHandler(this.EndAcquireState)); app.ReleaseRequestState += new EventHandler(this.OnReleaseState); app.EndRequest += new EventHandler(this.OnEndRequest); this._partitionResolver = this.InitPartitionResolver(config); switch (config.Mode) { case SessionStateMode.InProc: if (HttpRuntime.UseIntegratedPipeline) { s_canSkipEndRequestCall = true; } this._store = new InProcSessionStateStore(); this._store.Initialize(null, null); break; case SessionStateMode.StateServer: if (HttpRuntime.UseIntegratedPipeline) { s_canSkipEndRequestCall = true; } this._store = new OutOfProcSessionStateStore(); ((OutOfProcSessionStateStore) this._store).Initialize(null, null, this._partitionResolver); break; case SessionStateMode.SQLServer: this._store = new SqlSessionStateStore(); ((SqlSessionStateStore) this._store).Initialize(null, null, this._partitionResolver); break; case SessionStateMode.Custom: this._store = this.InitCustomStore(config); break; } this._idManager = this.InitSessionIDManager(config); if (((config.Mode == SessionStateMode.InProc) || (config.Mode == SessionStateMode.StateServer)) && this._usingAspnetSessionIdManager) { this._ignoreImpersonation = true; } } }