protected void Application_Start(object sender, EventArgs e) { new AutoMapperConfigurator().Config( WebContainerManager.GetAll <IAutoMapperTypeConfigurator>()); // see Thinktecture.IdentityModel.Web using PassiveSessionConfiguration.ConfigureMackineKeyProtectionForSessionTokens(); RegisterExceptionHandler(); }
public void Configure() { if (!String.IsNullOrWhiteSpace(this.config.SessionTokenCacheType)) { var type = Type.GetType(this.config.SessionTokenCacheType); if (type == null) { throw new ConfigurationErrorsException("Invalid SessionTokenCacheType: " + config.SessionTokenCacheType); } var obj = Activator.CreateInstance(type); if (obj == null) { throw new Exception("Failed to create instance of " + config.SessionTokenCacheType); } var cache = obj as ITokenCacheRepository; if (cache == null) { throw new Exception(config.SessionTokenCacheType + " does not implement ITokenCacheRepository interface"); } PassiveSessionConfiguration.ConfigureSessionCache(cache); } if (this.config.UseMackineKeyProtectionForSessionTokens) { PassiveSessionConfiguration.ConfigureMackineKeyProtectionForSessionTokens(); } if (this.config.PersistentSessionDuration > TimeSpan.Zero) { PassiveSessionConfiguration.ConfigureDefaultSessionDuration(this.config.PersistentSessionDuration); } else if (this.config.DefaultSessionDuration > TimeSpan.Zero) { PassiveSessionConfiguration.ConfigureDefaultSessionDuration(this.config.DefaultSessionDuration); } if (this.RequiresModuleConfig) { SessionConfigurationModule.CacheSessionsOnServer = config.CacheSessionsOnServer; SessionConfigurationModule.EnableSlidingSessionExpirations = config.EnableSlidingSessionExpirations; SessionConfigurationModule.OverrideWSFedTokenLifetime = config.OverrideWSFedTokenLifetime; SessionConfigurationModule.SuppressLoginRedirectsForApiCalls = config.SuppressLoginRedirectsForApiCalls; SessionConfigurationModule.SuppressSecurityTokenExceptions = config.SuppressSecurityTokenExceptions; SessionConfigurationModule.EnablePersistentSessions = config.PersistentSessionDuration > TimeSpan.Zero; DynamicModuleUtility.RegisterModule(typeof(SessionConfigurationModule)); } }