internal void SetSessionStateMode(HttpContextBase context, IDynamicSessionStateConfigurator configurator) { MvcHandler mvcHandler = context.Handler as MvcHandler; if (mvcHandler == null) { // Either MvcHttpHandler was called directly, Routing hasn't run, or Routing has run // and the chosen handler isn't MVC. There's nothing we can do here. return; } // Check to see that our factory is installed, otherwise the controller factory might be asked to // create two instances of the controller for every request, which could lead to resource or // scalability issues. RequestContext requestContext = mvcHandler.RequestContext; MvcDynamicSessionControllerFactory factory = ControllerBuilder.GetControllerFactory() as MvcDynamicSessionControllerFactory; if (factory == null) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, MvcResources.MvcDynamicSessionModule_WrongControllerFactory, typeof(MvcDynamicSessionControllerFactory))); } context.Items[_controllerFactoryItemKey] = factory; // save a reference to this factory so that we can dispose of the cached controller string controllerName = requestContext.RouteData.GetRequiredString("controller"); IController controller = factory.CreateCachedController(requestContext, controllerName); ControllerSessionState sessionStateMode = GetSessionStateMode(controller); configurator.ConfigureSessionState(sessionStateMode); }
public void ConfigureSessionState(ControllerSessionState mode) { if (!_expectedMode.HasValue) { Assert.Fail("ConfigureSessionState shouldn't have been called."); } Assert.AreEqual(_expectedMode, mode, "ConfigureSessionState called with wrong mode."); }
public void ConfigureSessionState(ControllerSessionState mode) { switch (mode) { case ControllerSessionState.Disabled: _httpContext.Handler = new MvcDynamicSessionHandler((MvcHandler)_httpContext.Handler); break; case ControllerSessionState.ReadOnly: _httpContext.Handler = new MvcReadOnlySessionHandler((MvcHandler)_httpContext.Handler); break; default: // Let the default MvcHandler take care of everything else. break; } }
public void ConfigureSessionState(ControllerSessionState mode) { switch (mode) { case ControllerSessionState.Disabled: _httpContext.Handler = new MvcDynamicSessionHandler((MvcHandler)_httpContext.Handler); break; case ControllerSessionState.ReadOnly: _httpContext.Handler = new MvcReadOnlySessionHandler((MvcHandler)_httpContext.Handler); break; default: // Let the default MvcHandler take care of everything else. break; } }
public void ConfigureSessionState(HttpContextBase httpContext, ControllerSessionState mode) { _setter(httpContext, (int)mode); }
public void ConfigureSessionState(ControllerSessionState mode) { Executor executor = _executorFunc.Eval(); executor.ConfigureSessionState(_httpContext, mode); }
public static SimpleDynamicSessionStateConfigurator ExpectMode(ControllerSessionState mode) { return new SimpleDynamicSessionStateConfigurator(mode); }
public void ConfigureSessionState(ControllerSessionState mode) { if (!_expectedMode.HasValue) { Assert.Fail("ConfigureSessionState shouldn't have been called."); } Assert.AreEqual(_expectedMode, mode, "ConfigureSessionState called with wrong mode."); }
private SimpleDynamicSessionStateConfigurator(ControllerSessionState? expectedMode) { _expectedMode = expectedMode; }
public void ConfigureSessionState(HttpContextBase httpContext, ControllerSessionState mode) { _setter(httpContext, (int)mode); }
public void ConfigureSessionState(ControllerSessionState mode) { Executor executor = _executorFunc.Eval(); executor.ConfigureSessionState(_httpContext, mode); }
public static SimpleDynamicSessionStateConfigurator ExpectMode(ControllerSessionState mode) { return(new SimpleDynamicSessionStateConfigurator(mode)); }
public ControllerSessionStateAttribute(ControllerSessionState mode) { Mode = mode; }
public ControllerSessionStateAttribute(ControllerSessionState mode) { Mode = mode; }