private static HttpSessionState CreateSessionState(string key, object state) { string id = key.Substring(CACHEKEYPREFIXLENGTH); ISessionStateItemCollection sessionItems = (ISessionStateItemCollection)ExpressionEvaluator.GetValue(state, "_sessionItems"); HttpStaticObjectsCollection staticObjects = (HttpStaticObjectsCollection)ExpressionEvaluator.GetValue(state, "_staticObjects"); int timeout = (int)ExpressionEvaluator.GetValue(state, "_timeout"); TypeRegistry.RegisterType("SessionStateModule", typeof(SessionStateModule)); HttpCookieMode cookieMode = (HttpCookieMode)ExpressionEvaluator.GetValue(null, "SessionStateModule.s_configCookieless"); SessionStateMode stateMode = (SessionStateMode)ExpressionEvaluator.GetValue(null, "SessionStateModule.s_configMode"); HttpSessionStateContainer container = new HttpSessionStateContainer( id , sessionItems , staticObjects , timeout , false , cookieMode , stateMode , true ); return((HttpSessionState)Activator.CreateInstance( typeof(HttpSessionState) , BindingFlags.Instance | BindingFlags.NonPublic , null , new object[] { container } , CultureInfo.InvariantCulture )); }
public HttpSessionStateContainer(string id, ISessionStateItemCollection sessionItems, HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, HttpCookieMode cookieMode, SessionStateMode mode, bool isReadonly) : this(null, id, sessionItems, staticObjects, timeout, newSession, cookieMode, mode, isReadonly) { if (id == null) { throw new ArgumentNullException("id"); } }
protected virtual void Reset() { _sessionID = Guid.NewGuid().ToString(); _isNewSession = false; _isCookieless = false; _mode = SessionStateMode.InProc; _codePage = -1; _cookieMode = HttpCookieMode.AutoDetect; }
internal bool SetMode(string value) { try { Mode = (SessionStateMode)Enum.Parse(typeof(SessionStateMode), value, true); } catch { return(false); } return(true); }
/// <summary> /// Initializes a new instance of the <see cref="FakeHttpSessionState"/> class. /// </summary> public FakeHttpSessionState() { this.sessionItems = new NameObjectCollection<object>(StringComparer.InvariantCultureIgnoreCase); this.staticObjects = new HttpStaticObjectsCollectionWrapper(new HttpStaticObjectsCollection()); this.cookieMode = HttpCookieMode.UseCookies; this.isNewSession = true; this.mode = SessionStateMode.InProc; this.sessionID = Guid.NewGuid().ToString("N"); }
internal bool SetMode (string value) { try { Mode = (SessionStateMode) Enum.Parse (typeof (SessionStateMode), value, true); } catch { return false; } return true; }
public TaskWaitRedisHttpSessionStateContainer(string id, RedisSessionItemHash sessionItems, HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, HttpCookieMode cookieMode, SessionStateMode mode, bool isReadonly) : base(id, sessionItems, staticObjects, timeout, newSession, cookieMode, mode, isReadonly) { SessionItems = sessionItems; }
internal HttpSessionStateContainer(SessionStateModule stateModule, string id, ISessionStateItemCollection sessionItems, HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, HttpCookieMode cookieMode, SessionStateMode mode, bool isReadonly) { this._stateModule = stateModule; this._id = id; this._sessionItems = sessionItems; this._staticObjects = staticObjects; this._timeout = timeout; this._newSession = newSession; this._cookieMode = cookieMode; this._mode = mode; this._isReadonly = isReadonly; }
/// <summary> /// Initialize the module /// </summary> /// <param name="app"></param> public void Init(HttpApplication app) { bool initModuleCalled = false; if (!s_oneTimeInit) { lock (LockObject) { if (!s_oneTimeInit) { s_config = ConfigurationManager.GetSection("system.web/sessionState") as SessionStateSection; if (s_config == null) { throw new ConfigurationErrorsException(string.Format(SR.Error_Occured_Reading_Config_Secion, "system.web/sessionState")); } InitModuleFromConfig(app, s_config); initModuleCalled = true; s_timeout = (int)s_config.Timeout.TotalMinutes; var section = ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection; if (section == null) { throw new ConfigurationErrorsException(string.Format(SR.Error_Occured_Reading_Config_Secion, "system.web/httpRuntime")); } s_configExecutionTimeout = section.ExecutionTimeout; s_configRegenerateExpiredSessionId = s_config.RegenerateExpiredSessionId; s_configCookieless = s_config.Cookieless; s_configMode = s_config.Mode; if (!s_pollIntervalRegLookedUp) { LookUpRegForPollInterval(); } // The last thing to set in this if-block. s_oneTimeInit = true; } } } if (!initModuleCalled) { InitModuleFromConfig(app, s_config); } }
public void Init(HttpApplication app) { bool flag = false; SessionStateSection sessionState = RuntimeConfig.GetAppConfig().SessionState; if (!this.s_oneTimeInit) { s_lock.AcquireWriterLock(); try { if (!this.s_oneTimeInit) { this.InitModuleFromConfig(app, sessionState); flag = true; if (!CheckTrustLevel(sessionState)) { s_trustLevelInsufficient = true; } s_timeout = (int)sessionState.Timeout.TotalMinutes; s_useHostingIdentity = sessionState.UseHostingIdentity; if ((sessionState.Mode == SessionStateMode.InProc) && this._usingAspnetSessionIdManager) { s_allowInProcOptimization = true; } if (((sessionState.Mode != SessionStateMode.Custom) && (sessionState.Mode != SessionStateMode.Off)) && !sessionState.RegenerateExpiredSessionId) { s_allowDelayedStateStoreItemCreation = true; } s_configExecutionTimeout = RuntimeConfig.GetConfig().HttpRuntime.ExecutionTimeout; s_configRegenerateExpiredSessionId = sessionState.RegenerateExpiredSessionId; s_configCookieless = sessionState.Cookieless; s_configMode = sessionState.Mode; this.s_oneTimeInit = true; } } finally { s_lock.ReleaseWriterLock(); } } if (!flag) { this.InitModuleFromConfig(app, sessionState); } if (s_trustLevelInsufficient) { throw new HttpException(System.Web.SR.GetString("Session_state_need_higher_trust")); } }
SessionStateModule _stateModule; // used for optimized InProc session id callback public HttpSessionStateContainer( String id, ISessionStateItemCollection sessionItems, HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, HttpCookieMode cookieMode, SessionStateMode mode, bool isReadonly) : this(null, id, sessionItems, staticObjects, timeout, newSession, cookieMode, mode, isReadonly) { if (id == null) { throw new ArgumentNullException("id"); } }
public SessionConfig (object parent) { SessionConfig p = (parent as SessionConfig); if (p != null) { CookieLess = p.CookieLess; Mode = p.Mode; Timeout = p.Timeout; StateConnectionString = p.StateConnectionString; SqlConnectionString = p.SqlConnectionString; } else { Mode = SessionStateMode.InProc; Timeout = 20; StateConnectionString = "127.0.0.1:42424"; SqlConnectionString = "user id=sa;password=;data source=127.0.0.1"; } }
protected static HttpSessionState CreateSession() { HttpSessionState sessionState; string id = Guid.NewGuid().ToString(); HttpStaticObjectsCollection staticObjects = new HttpStaticObjectsCollection(); int timeout = 20; bool newSession = true; SessionStateMode mode = SessionStateMode.InProc; bool isReadOnly = false; SessionStateItemCollection sessionItems = new SessionStateItemCollection(); HttpSessionStateContainer httpSessionStateContainer = new HttpSessionStateContainer( id, sessionItems, staticObjects, timeout, newSession, HttpCookieMode.UseUri, mode, isReadOnly); sessionState = (HttpSessionState)PrivateInvoke.CreateInstanceNonPublicCtor(typeof(HttpSessionState), httpSessionStateContainer); return(sessionState); }
internal HttpSessionState (string id, SessionDictionary dict, HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, bool isCookieless, SessionStateMode mode, bool isReadonly) { _id = id; _dict = dict; _staticObjects = staticObjects.Clone (); _timeout = timeout; _newSession = newSession; _isCookieless = isCookieless; _mode = mode; _isReadonly = isReadonly; }
public MySessionState(string id, ISessionStateItemCollection sessionItems, HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, HttpCookieMode cookieMode, SessionStateMode mode, bool isReadonly) { pId = id; pSessionItems = sessionItems; pStaticObjects = staticObjects; pTimeout = timeout; pNewSession = newSession; pCookieMode = cookieMode; pMode = mode; pIsReadonly = isReadonly; }
internal HttpSessionState(string id, SessionDictionary dict, HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, bool isCookieless, SessionStateMode mode, bool isReadonly) { _id = id; _dict = dict; _staticObjects = staticObjects.Clone(); _timeout = timeout; _newSession = newSession; _isCookieless = isCookieless; _mode = mode; _isReadonly = isReadonly; }
/// <summary> /// Необходима для подключения StsStateKeeper, в случае если PageState или Session хранится в InMsSql InSession StateServer SQLServer /// </summary> /// <param name="e"></param> protected override void OnLoad(EventArgs e) { ViewStateModes viewStateMode = Globals.Settings.ViewState.ViewStateMode; SessionStateMode stateMode = HttpContext.Current.Session == null ? SessionStateMode.Off : Page.Session.Mode; if (viewStateMode == ViewStateModes.InMsSql || viewStateMode == ViewStateModes.InSession || stateMode == SessionStateMode.StateServer || stateMode == SessionStateMode.SQLServer) { if (Page.IsPostBack) { //todo: Сюда или в Init добавить обработку метки времени, это позволит понять что страница устарела. } //todo: проанализировать какой вариант лучше на практике. //Page.Form.Controls.Add(new StsStateKeeper(this)); AddTimeStampField(); AddStateKeeperScript(); } base.OnLoad(e); }
public SessionConfig(object parent) { SessionConfig p = (parent as SessionConfig); if (p != null) { CookieLess = p.CookieLess; Mode = p.Mode; Timeout = p.Timeout; StateConnectionString = p.StateConnectionString; SqlConnectionString = p.SqlConnectionString; } else { Mode = SessionStateMode.InProc; Timeout = 20; StateConnectionString = "127.0.0.1:42424"; SqlConnectionString = "user id=sa;password=;data source=127.0.0.1"; } }
internal HttpSessionStateContainer( SessionStateModule stateModule, string id, ISessionStateItemCollection sessionItems, HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, HttpCookieMode cookieMode, SessionStateMode mode, bool isReadonly) { _stateModule = stateModule; _id = id; // If null, it means we're delaying session id reading _sessionItems = sessionItems; _staticObjects = staticObjects; _timeout = timeout; _newSession = newSession; _cookieMode = cookieMode; _mode = mode; _isReadonly = isReadonly; }
public override void Init() { base.Init(); foreach (string moduleName in this.Modules) { string appName = "APPNAME1"; IHttpModule module = this.Modules[moduleName]; SessionStateModule ssm = module as SessionStateModule; if (ssm != null) { FieldInfo storeInfo = typeof(SessionStateModule).GetField("_store", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo configMode = typeof(SessionStateModule).GetField("s_configMode", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static); SessionStateMode mode = (SessionStateMode)configMode.GetValue(ssm); if (mode == SessionStateMode.StateServer) { SessionStateStoreProviderBase store = (SessionStateStoreProviderBase)storeInfo.GetValue(ssm); if (store == null)//In IIS7 Integrated mode, module.Init() is called later { FieldInfo runtimeInfo = typeof(HttpRuntime).GetField("_theRuntime", BindingFlags.Static | BindingFlags.NonPublic); HttpRuntime theRuntime = (HttpRuntime)runtimeInfo.GetValue(null); FieldInfo appNameInfo = typeof(HttpRuntime).GetField("_appDomainAppId", BindingFlags.Instance | BindingFlags.NonPublic); appNameInfo.SetValue(theRuntime, appName); } else { Type storeType = store.GetType(); if (storeType.Name.Equals("OutOfProcSessionStateStore")) { FieldInfo uribaseInfo = storeType.GetField("s_uribase", BindingFlags.Static | BindingFlags.NonPublic); uribaseInfo.SetValue(storeType, appName); object obj = null; uribaseInfo.GetValue(obj); } } } break; } } }
public HttpSessionStateContainer (string id, ISessionStateItemCollection sessionItems, HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, HttpCookieMode cookieMode, SessionStateMode mode, bool isReadonly) { if (id == null) throw new ArgumentNullException ("id"); this.sessionItems = sessionItems; this.id = id; this.staticObjects = staticObjects; this.timeout = timeout; this.newSession = newSession; this.cookieMode = cookieMode; this.mode = mode; this.isReadOnly = isReadonly; this.isCookieless = cookieMode == HttpCookieMode.UseUri; }
public HttpSessionStateContainer(string id, ISessionStateItemCollection sessionItems, HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, HttpCookieMode cookieMode, SessionStateMode mode, bool isReadonly) { if (id == null) { throw new ArgumentNullException("id"); } this.sessionItems = sessionItems; this.id = id; this.staticObjects = staticObjects; this.timeout = timeout; this.newSession = newSession; this.cookieMode = cookieMode; this.mode = mode; this.isReadOnly = isReadonly; this.isCookieless = cookieMode == HttpCookieMode.UseUri; }
public void SetMode(SessionStateMode val) { _mode = val; }
public void Init(HttpApplication app) { bool flag = false; SessionStateSection sessionState = RuntimeConfig.GetAppConfig().SessionState; if (!this.s_oneTimeInit) { s_lock.AcquireWriterLock(); try { if (!this.s_oneTimeInit) { this.InitModuleFromConfig(app, sessionState); flag = true; if (!CheckTrustLevel(sessionState)) { s_trustLevelInsufficient = true; } s_timeout = (int) sessionState.Timeout.TotalMinutes; s_useHostingIdentity = sessionState.UseHostingIdentity; if ((sessionState.Mode == SessionStateMode.InProc) && this._usingAspnetSessionIdManager) { s_allowInProcOptimization = true; } if (((sessionState.Mode != SessionStateMode.Custom) && (sessionState.Mode != SessionStateMode.Off)) && !sessionState.RegenerateExpiredSessionId) { s_allowDelayedStateStoreItemCreation = true; } s_configExecutionTimeout = RuntimeConfig.GetConfig().HttpRuntime.ExecutionTimeout; s_configRegenerateExpiredSessionId = sessionState.RegenerateExpiredSessionId; s_configCookieless = sessionState.Cookieless; s_configMode = sessionState.Mode; this.s_oneTimeInit = true; } } finally { s_lock.ReleaseWriterLock(); } } if (!flag) { this.InitModuleFromConfig(app, sessionState); } if (s_trustLevelInsufficient) { throw new HttpException(System.Web.SR.GetString("Session_state_need_higher_trust")); } }
/// <summary> /// Sets the current session-state mode. /// </summary> /// <param name="mode">The mode.</param> public void SetMode(SessionStateMode mode) { this.mode = mode; }
public HttpSessionStateContainer(string id, ISessionStateItemCollection sessionItems, System.Web.HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, System.Web.HttpCookieMode cookieMode, SessionStateMode mode, bool isReadonly) { }
/// <summary> /// Session을 사용하지 않도록 설정했다면 예외를 발생시킨다. /// </summary> /// <param name="mode"></param> private static void ThrowIfSessionStateModeIsOff(SessionStateMode mode) { Guard.Assert(mode != SessionStateMode.Off, "프로그램 또는 Page가 Session을 사용하지 않기 때문에 ViewState정보를 Session에 저장하지 못했습니다."); }
// Constructors public HttpSessionStateContainer(string id, ISessionStateItemCollection sessionItems, System.Web.HttpStaticObjectsCollection staticObjects, int timeout, bool newSession, System.Web.HttpCookieMode cookieMode, SessionStateMode mode, bool isReadonly) { }
public void Init(HttpApplication app) { bool initModuleCalled = false; SessionStateSection config = RuntimeConfig.GetAppConfig().SessionState; if (!s_oneTimeInit) { s_lock.AcquireWriterLock(); try { if (!s_oneTimeInit) { InitModuleFromConfig(app, config); initModuleCalled = true; if (!CheckTrustLevel(config)) s_trustLevelInsufficient = true; s_timeout = (int)config.Timeout.TotalMinutes; s_useHostingIdentity = config.UseHostingIdentity; // See if we can try InProc optimization. See inline doc of s_allowInProcOptimization // for details. if (config.Mode == SessionStateMode.InProc && _usingAspnetSessionIdManager) { s_allowInProcOptimization = true; } if (config.Mode != SessionStateMode.Custom && config.Mode != SessionStateMode.Off && !config.RegenerateExpiredSessionId) { s_allowDelayedStateStoreItemCreation = true; } s_configExecutionTimeout = RuntimeConfig.GetConfig().HttpRuntime.ExecutionTimeout; s_configRegenerateExpiredSessionId = config.RegenerateExpiredSessionId; s_configCookieless = config.Cookieless; s_configMode = config.Mode; // The last thing to set in this if-block. s_oneTimeInit = true; Debug.Trace("SessionStateModuleInit", "Configuration: _mode=" + config.Mode + ";Timeout=" + config.Timeout + ";CookieMode=" + config.Cookieless + ";SqlConnectionString=" + config.SqlConnectionString + ";StateConnectionString=" + config.StateConnectionString + ";s_allowInProcOptimization=" + s_allowInProcOptimization + ";s_allowDelayedStateStoreItemCreation=" + s_allowDelayedStateStoreItemCreation); } } finally { s_lock.ReleaseWriterLock(); } } if (!initModuleCalled) { InitModuleFromConfig(app, config); } if (s_trustLevelInsufficient) { throw new HttpException(SR.GetString(SR.Session_state_need_higher_trust)); } }
public FakeHttpSessionStateBase(SessionStateMode mode = SessionStateMode.Off) { _mode = mode; }
public void SetMode(SessionStateMode val) { }