Just FYI I've added an issue to the tracker for this:
http://issues.umbraco.org/issue/U4-5208
There is a work around though:
Create a custom async render action invoke (as per above):
public class FixedAsyncRenderActionInvoker : System.Web.Mvc.Async.AsyncControllerActionInvoker
{
protected override ActionDescriptor FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, string actionName)
{
var ad = base.FindAction(controllerContext, controllerDescriptor, actionName);
if (ad == null)
{
//check if the controller is an instance of IRenderMvcController
if (controllerContext.Controller is IRenderMvcController)
{
return new ReflectedActionDescriptor(
controllerContext.Controller.GetType().GetMethods()
.First(x => x.Name == "Index" &&
x.GetCustomAttributes(typeof(NonActionAttribute), false).Any() == false),
"Index",
controllerDescriptor);
}
}
return ad;
}
}
Create a custom render mvc controller:
public class FixedAsyncRenderMvcController : RenderMvcController
{
public FixedAsyncRenderMvcController()
{
this.ActionInvoker = new FixedAsyncRenderActionInvoker();
}
}
Create a custom render controller factory:
public class FixedAsyncRenderControllerFactory : RenderControllerFactory
{
public override IController CreateController(RequestContext requestContext, string controllerName)
{
var controller1 = base.CreateController(requestContext, controllerName);
var controller2 = controller1 as Controller;
if (controller2 != null)
controller2.ActionInvoker = new FixedAsyncRenderActionInvoker();
return controller1;
}
}
Create an umbraco startup handler and replace the necessary parts with the above custom parts:
public class UmbracoStartupHandler : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
DefaultRenderMvcControllerResolver.Current.SetDefaultControllerType(typeof(FixedAsyncRenderMvcController));
FilteredControllerFactoriesResolver.Current.RemoveType<RenderControllerFactory>();
FilteredControllerFactoriesResolver.Current.AddType<FixedAsyncRenderControllerFactory>();
base.ApplicationStarting(umbracoApplication, applicationContext);
}
}
Task<ActionResult>
to a string indicates that it does not understandasync
methods. You might need to contact the Umbraco community directly, and/or put in a feature request. – Stephen ClearyUmbraco.Web.Mvc.SurfaceController
but this is still an issue for controllers that implement IRenderMvcController. I've raised it as an issue here and written about a workaround here. – Digbyswift