Ejemplo n.º 1
0
        public void Init(HttpApplication app)
        {
            sessionForStaticFiles = (Environment.GetEnvironmentVariable("MONO_XSP_STATIC_SESSION") != null);
            SessionConfig cfg = GetConfig();

            if (handlerType == null)
            {
                return;
            }

            if (cfg.CookieLess)
            {
                app.BeginRequest += new EventHandler(OnBeginRequest);
            }

            app.AcquireRequestState += new EventHandler(OnAcquireState);
            app.ReleaseRequestState += new EventHandler(OnReleaseRequestState);
            app.EndRequest          += new EventHandler(OnEndRequest);

            if (handlerType != null && handler == null)
            {
                handler = (ISessionHandler)Activator.CreateInstance(handlerType);
                handler.Init(this, app, cfg);                  //initialize
            }
        }
		public void Init (HttpApplication app)
		{
			sessionForStaticFiles = (Environment.GetEnvironmentVariable ("MONO_XSP_STATIC_SESSION") != null);
			if (config == null) {
				config = (SessionConfig) HttpContext.GetAppConfig ("system.web/sessionState");
				if (config ==  null)
					config = new SessionConfig (null);

				if (config.Mode == SessionStateMode.StateServer)
					handlerType = typeof (SessionStateServerHandler);

				if (config.Mode == SessionStateMode.SQLServer)
					handlerType = typeof (SessionSQLServerHandler);
				
				if (config.Mode == SessionStateMode.InProc)
					handlerType = typeof (SessionInProcHandler);

                                if (config.Mode == SessionStateMode.Off)
                                        return;
			}

			if (config.CookieLess)
				app.BeginRequest += new EventHandler (OnBeginRequest);
			
			app.AddOnAcquireRequestStateAsync (
				new BeginEventHandler (OnBeginAcquireState),
				new EndEventHandler (OnEndAcquireState));

			app.ReleaseRequestState += new EventHandler (OnReleaseRequestState);
			app.EndRequest += new EventHandler (OnEndRequest);
			
			if (handlerType != null && handler == null) {
				handler = (ISessionHandler) Activator.CreateInstance (handlerType);
				handler.Init (this, app, config); //initialize
			}
		}