private static void UseMvc(HttpServerSimulator server, IMvcApplication mvcApplication)
        {
            SimulatorHelper.InitializeMembership();

            server.Use(httpContext =>
            {
                var action = new HttpControllerAction(mvcApplication, httpContext);
                var executionContext = action.GetExecutionContext();

                if (executionContext != null)
                {
                    var actionResult = action.GetAuthorizationResult(executionContext);

                    if (actionResult == null)
                    {
                        action.ValidateRequest(executionContext);
                        actionResult = action.GetActionResult(executionContext);
                    }

                    actionResult.ExecuteResult(executionContext.ControllerContext);
                    return true;
                }

                return false;
            });
        }
Exemplo n.º 2
0
        public bool Handle(HttpListenerContext httpContext)
        {
            var httpContextBase = Wrap(httpContext, _server.Sessions);

            _server.OnEnter(httpContextBase);

            var action           = new HttpControllerAction(_mvcApplication, httpContextBase);
            var executionContext = action.GetExecutionContext();

            if (executionContext != null)
            {
                var actionResult = action.GetAuthorizationResult(executionContext);

                if (actionResult == null)
                {
                    action.ValidateRequest(executionContext);
                    actionResult = action.GetActionResult(executionContext);
                }

                actionResult.ExecuteResult(executionContext);

                // close the response to enforce flush of the content
                httpContextBase.Response.Close();

                return(true);
            }

            return(false);
        }