From cd401f5e37b8517c2a6d39e2746d8295d56ebf92 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 21 Mar 2016 16:12:34 +0100 Subject: [PATCH] U4-8216 Hijacked controller actions fail with custom RenderModel subclass due to ModelBinding error --- src/Umbraco.Web/Mvc/RenderModelBinder.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web/Mvc/RenderModelBinder.cs b/src/Umbraco.Web/Mvc/RenderModelBinder.cs index 149194dbd0..735f015afc 100644 --- a/src/Umbraco.Web/Mvc/RenderModelBinder.cs +++ b/src/Umbraco.Web/Mvc/RenderModelBinder.cs @@ -174,9 +174,15 @@ namespace Umbraco.Web.Mvc public IModelBinder GetBinder(Type modelType) { - return TypeHelper.IsTypeAssignableFrom(modelType) || TypeHelper.IsTypeAssignableFrom(modelType) - ? this - : null; + // can bind to RenderModel (exact type match) + if (modelType == typeof(RenderModel)) return this; + + // can bind to RenderModel (exact generic type match) + if (modelType.IsGenericType && modelType.GetGenericTypeDefinition() == typeof(RenderModel<>)) return this; + + // can bind to TContent where TContent : IPublishedContent (any IPublishedContent implementation) + if (typeof(IPublishedContent).IsAssignableFrom(modelType)) return this; + return null; } } } \ No newline at end of file