/// <summary> /// The job of this method is invoke an action and ultimately populate the /// </summary> /// <param name="application">The current application</param> /// <param name="context">A context which stores the request and response contexts.</param> public async Task Execute(MvcApplication application, NavigationContext context) { Initialize(application, context); var action = RouteData.Action; var actionResult = await ActionInvoker.InvokeAction(ControllerContext, action); var view = ((ViewResult)actionResult).View; view.Initialize(application.CreateViewContext(this)); context.Response.View = view; }
private NavigationContext CreateNavigationContext(string path, string queryString) { // Create http context var queryStringDictionary = new Dictionary<string, string>(); if (queryString != null) { var parts = queryString.Split(new[] { '&' }); foreach (var part in parts) { var pair = part.Split(new[] { '=' }); var key = HttpUtility.UrlDecode(pair[0]); var value = HttpUtility.UrlDecode(pair[1]); queryStringDictionary[key] = value; } } var routeData = routeTree.Apply(path, "GET"); var request = new NavigationRequest { Path = path, QueryString = queryStringDictionary, RouteData = routeData }; var response = new NavigationResponse(); var navigationContext = new NavigationContext { Request = request, Response = response }; return navigationContext; }
public override void ExecuteResult(NavigationContext context) { }
protected virtual void Initialize(MvcApplication application, NavigationContext requestContext) { NavigationContext = requestContext; ActionInvoker = new ControllerActionInvoker(); ControllerContext = new ControllerContext { Application = application, NavigationContext = NavigationContext, Controller = this }; }