/// <summary> /// this will determine the controller and set the values in the route data /// </summary> /// <param name="requestContext"></param> /// <param name="publishedContentRequest"></param> internal IHttpHandler GetHandlerForRoute(RequestContext requestContext, PublishedContentRequest publishedContentRequest) { var routeDef = GetUmbracoRouteDefinition(requestContext, publishedContentRequest); //Need to check for a special case if there is form data being posted back to an Umbraco URL var postedInfo = GetPostedFormInfo(requestContext); if (postedInfo != null) { return(HandlePostedValues(requestContext, postedInfo, routeDef)); } //here we need to check if there is no hijacked route and no template assigned, if this is the case //we want to return a blank page, but we'll leave that up to the NoTemplateHandler. if (!publishedContentRequest.HasTemplate && !routeDef.HasHijackedRoute) { var handler = publishedContentRequest.ProcessNoTemplateInMvc(requestContext.HttpContext); //though this code should never execute if the ProcessNoTemplateInMvc method redirects, it seems that we should check it //and return null, this could be required for unit testing as well if (publishedContentRequest.IsRedirect) { return(null); } // if it's not null it can be either the PublishedContentNotFoundHandler (no document was // found to handle 404, or document with no template was found) or the WebForms handler // (a document was found and its template is WebForms) // if it's null it means that a document was found and its template is Mvc // if we have a handler, return now if (handler != null) { return(handler); } // else we are running Mvc // update the route definition routeDef = GetUmbracoRouteDefinition(requestContext, publishedContentRequest); } //no post values, just route to the controller/action requried (local) requestContext.RouteData.Values["controller"] = routeDef.ControllerName; if (!string.IsNullOrWhiteSpace(routeDef.ActionName)) { requestContext.RouteData.Values["action"] = routeDef.ActionName; } // reset the friendly path so in the controllers and anything occuring after this point in time, //the URL is reset back to the original request. requestContext.HttpContext.RewritePath(UmbracoContext.OriginalRequestUrl.PathAndQuery); return(new MvcHandler(requestContext)); }