Merge remote-tracking branch 'origin/6.0.7' into 6.1.2

Conflicts:
	src/Umbraco.Web/Mvc/RenderControllerFactory.cs
	src/Umbraco.Web/Mvc/RenderMvcController.cs
	src/Umbraco.Web/Mvc/RenderRouteHandler.cs
	src/Umbraco.Web/Umbraco.Web.csproj
This commit is contained in:
Shannon
2013-06-25 09:41:27 +10:00
6 changed files with 39 additions and 5 deletions

View File

@@ -0,0 +1,18 @@
using System.Web.Mvc;
using Umbraco.Web.Models;
namespace Umbraco.Web.Mvc
{
/// <summary>
/// The interface that must be implemented for a controller to be designated to execute for route hijacking
/// </summary>
public interface IRenderMvcController : IController
{
/// <summary>
/// The default action to render the front-end view
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
ActionResult Index(RenderModel model);
}
}

View File

@@ -22,8 +22,8 @@ namespace Umbraco.Web.Mvc
//now we need to check if it exists, if not we need to return the Index by default
if (ad == null)
{
//check if the controller is an instance of RenderMvcController
if (controllerContext.Controller is RenderMvcController)
//check if the controller is an instance of IRenderMvcController
if (controllerContext.Controller is IRenderMvcController)
{
return new ReflectedActionDescriptor(controllerContext.Controller.GetType().GetMethod("Index"), "Index", controllerDescriptor);
}

View File

@@ -22,5 +22,17 @@ namespace Umbraco.Web.Mvc
return dataToken == null || string.IsNullOrWhiteSpace(dataToken.ToString());
}
/// <remarks>
/// We always set the correct ActionInvoker on our custom created controller, this is very important for route hijacking!
/// </remarks>
var controllerInstance = instance as Controller;
if (controllerInstance != null)
{
//set the action invoker!
controllerInstance.ActionInvoker = new RenderActionInvoker();
}
return instance;
}
}

View File

@@ -271,7 +271,7 @@ namespace Umbraco.Web.Mvc
//check if that controller exists
if (controllerType != null)
{
//ensure the controller is of type 'RenderMvcController'
//ensure the controller is of type 'IRenderMvcController' and ControllerBase
if (TypeHelper.IsTypeAssignableFrom<RenderMvcController>(controllerType))
{
//set the controller and name to the custom one
@@ -285,10 +285,11 @@ namespace Umbraco.Web.Mvc
else
{
LogHelper.Warn<RenderRouteHandler>(
"The current Document Type {0} matches a locally declared controller of type {1}. Custom Controllers for Umbraco routing must inherit from '{2}'.",
"The current Document Type {0} matches a locally declared controller of type {1}. Custom Controllers for Umbraco routing must implement '{2}' and inherit from '{3}'.",
() => publishedContentRequest.PublishedContent.DocumentTypeAlias,
() => controllerType.FullName,
() => typeof (RenderMvcController).FullName);
() => typeof(IRenderMvcController).FullName,
() => typeof(ControllerBase).FullName);
//exit as we cannnot route to the custom controller, just route to the standard one.
return def;
}

View File

@@ -4,6 +4,8 @@ using System.Web.Routing;
namespace Umbraco.Web.Mvc
{
//NOTE: We currently are not using this at all and should/could probably remove it!
/// <summary>
/// Creates SurfaceControllers
/// </summary>

View File

@@ -357,6 +357,7 @@
<Compile Include="Mvc\MemberAuthorizeAttribute.cs" />
<Compile Include="Mvc\BackOfficeArea.cs" />
<Compile Include="Mvc\ControllerFactoryExtensions.cs" />
<Compile Include="Mvc\IRenderMvcController.cs" />
<Compile Include="Mvc\SurfaceRouteHandler.cs" />
<Compile Include="PublishedCache\XmlPublishedCache\RoutesCache.cs" />
<Compile Include="Routing\UrlProviderMode.cs" />