using Microsoft.AspNetCore.Mvc.ApplicationModels; using Microsoft.AspNetCore.Mvc.ModelBinding; using Umbraco.Web.Common.ModelBinding; using System.Linq; namespace Umbraco.Web.Common.ApplicationModels { /// /// Applies the body model binder to any parameter binding source of type /// /// /// For this to work Microsoft's own convention must be executed before this one /// public class UmbracoJsonModelBinderConvention : IActionModelConvention { public void Apply(ActionModel action) { foreach (var p in action.Parameters.Where(p => p.BindingInfo?.BindingSource == BindingSource.Body)) { p.BindingInfo.BinderType = typeof(UmbracoJsonModelBinder); } } } }