From 3d2437613679ffe56feef2b673a758a469dc4d41 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 20 Jan 2021 15:38:21 +1100 Subject: [PATCH] missing file --- .../AspNetCore/UmbracoViewPage.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.Common/AspNetCore/UmbracoViewPage.cs b/src/Umbraco.Web.Common/AspNetCore/UmbracoViewPage.cs index 4fe3b268c0..cd429ec458 100644 --- a/src/Umbraco.Web.Common/AspNetCore/UmbracoViewPage.cs +++ b/src/Umbraco.Web.Common/AspNetCore/UmbracoViewPage.cs @@ -56,7 +56,7 @@ namespace Umbraco.Web.Common.AspNetCore { // Here we do the magic model swap ViewContext ctx = value; - ctx.ViewData = BindViewData(ctx.HttpContext, ctx.ViewData); + ctx.ViewData = BindViewData(ctx.HttpContext.RequestServices.GetRequiredService(), ctx.ViewData); base.ViewContext = ctx; } } @@ -123,8 +123,18 @@ namespace Umbraco.Web.Common.AspNetCore /// or . This will use the to bind the models /// to the correct output type. /// - protected ViewDataDictionary BindViewData(HttpContext context, ViewDataDictionary viewData) + protected ViewDataDictionary BindViewData(ContentModelBinder contentModelBinder, ViewDataDictionary viewData) { + if (contentModelBinder is null) + { + throw new ArgumentNullException(nameof(contentModelBinder)); + } + + if (viewData is null) + { + throw new ArgumentNullException(nameof(viewData)); + } + // check if it's already the correct type and continue if it is if (viewData is ViewDataDictionary vdd) { @@ -149,7 +159,6 @@ namespace Umbraco.Web.Common.AspNetCore viewData = MapViewDataDictionary(viewData, typeof(TModel)); // bind the model - var contentModelBinder = context.RequestServices.GetRequiredService(); var bindingContext = new DefaultModelBindingContext(); contentModelBinder.BindModel(bindingContext, viewDataModel, typeof(TModel));