diff --git a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs
index 6069060648..e09de33820 100644
--- a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs
+++ b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs
@@ -270,6 +270,12 @@ namespace Umbraco.Web.Mvc
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
diff --git a/src/Umbraco.Web/Routing/PublishedContentRequest.cs b/src/Umbraco.Web/Routing/PublishedContentRequest.cs
index 7df106c43e..93beadf729 100644
--- a/src/Umbraco.Web/Routing/PublishedContentRequest.cs
+++ b/src/Umbraco.Web/Routing/PublishedContentRequest.cs
@@ -32,7 +32,6 @@ namespace Umbraco.Web.Routing
///
///
///
- ///
///
internal void ProcessRequest(HttpContextBase httpContext, UmbracoContext umbracoContext, Action onSuccess)
{
@@ -107,6 +106,13 @@ namespace Umbraco.Web.Routing
onSuccess(this);
}
+ ///
+ /// After execution is handed off to MVC, we can finally check if the request has: No Template assigned and also the
+ /// route is not hijacked. When this occurs, we need to send the routing back through the builder to check for
+ /// not found handlers.
+ ///
+ ///
+ ///
internal IHttpHandler ProcessNoTemplateInMvc(HttpContextBase httpContext)
{
var content = this.PublishedContent;
@@ -117,7 +123,10 @@ namespace Umbraco.Web.Routing
// redirect if it has been flagged
if (this.IsRedirect)
+ {
httpContext.Response.Redirect(this.RedirectUrl, true);
+ }
+
// here .Is404 _has_ to be true
httpContext.Response.StatusCode = 404;
diff --git a/src/Umbraco.Web/Routing/PublishedContentRequestBuilder.cs b/src/Umbraco.Web/Routing/PublishedContentRequestBuilder.cs
index 6b8025cd29..c1fe63605e 100644
--- a/src/Umbraco.Web/Routing/PublishedContentRequestBuilder.cs
+++ b/src/Umbraco.Web/Routing/PublishedContentRequestBuilder.cs
@@ -174,7 +174,10 @@ namespace Umbraco.Web.Routing
///
/// Performs the document resolution second pass.
///
- /// The second pass consists in handling "not found", internal redirects, access validation, and template.
+ ///
+ /// The second pass consists in handling "not found", internal redirects, access validation, and template.
+ /// TODO: Rename this method accordingly .... but to what?
+ ///
internal void LookupDocument2()
{
const string tracePrefix = "LookupDocument2: ";
diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs
index 4b3367ef07..24292936cf 100644
--- a/src/Umbraco.Web/UmbracoModule.cs
+++ b/src/Umbraco.Web/UmbracoModule.cs
@@ -104,7 +104,8 @@ namespace Umbraco.Web
// instanciate a request a process
// important to use CleanedUmbracoUrl - lowercase path-only version of the current url
var docreq = new PublishedContentRequest(umbracoContext.CleanedUmbracoUrl, umbracoContext.RoutingContext);
- docreq.ProcessRequest(httpContext, umbracoContext, docreq2 => RewriteToUmbracoHandler(HttpContext.Current, uri.Query, docreq2.RenderingEngine));
+ docreq.ProcessRequest(httpContext, umbracoContext,
+ docreq2 => RewriteToUmbracoHandler(HttpContext.Current, uri.Query, docreq2.RenderingEngine));
}
///