예제 #1
0
        public override ActionExecutionContext GetExecutionContext()
        {
            var httpContext = HttpContext ?? AspNetUtility.GetContext(UriPath, HttpMethod, User ?? AspNetUtility.CreateAnonymousUser());

            var routeData = GetRouteData(httpContext);

            if (routeData == null)
            {
                return(null);
            }

            var controllerName = routeData.GetRequiredString("controller");

            var controller     = MvcApplication.ControllerFactory.CreateController(HttpContext, controllerName);
            var requestContext = new RequestContext(httpContext, routeData);

            var controllerContext = new ControllerContext(requestContext, controller);

            Initialize(controllerContext);

            return(new ActionExecutionContext(MvcApplication)
            {
                ControllerContext = controllerContext,
                ActionDescriptor = GetActionDescriptor(controller, routeData)
            });
        }
예제 #2
0
        public static HttpContextBase CreateHttpContext(this IControllerAction actionRequest, ActionDescriptor actionDescriptor)
        {
            var controllerDescriptor = actionDescriptor.ControllerDescriptor;
            var controllerName       = controllerDescriptor.ControllerName;

            var user        = actionRequest.User ?? AspNetUtility.CreateAnonymousUser();
            var httpContext =
                AspNetUtility.GetContext(String.Format("/{0}/{1}", controllerName, actionDescriptor.ActionName),
                                         actionRequest.HttpMethod, user);

            return(httpContext);
        }