From 3ceda381c54ca24cbcaa2ea17db4898fc9a12df1 Mon Sep 17 00:00:00 2001 From: Hermes Sbicego Date: Fri, 4 Sep 2020 09:12:10 +0200 Subject: [PATCH] Fix/8392 remeber me model state exception (#8410) @sebastienros this fixes the possible NRE that would happen for absent models from merged #8393 (see your comment there https://github.com/OrchardCMS/Orchard/pull/8393#issuecomment-686630198) --- src/Orchard/Mvc/ModelBinders/BooleanBinderProvider.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Orchard/Mvc/ModelBinders/BooleanBinderProvider.cs b/src/Orchard/Mvc/ModelBinders/BooleanBinderProvider.cs index 4de20c9a5..13905d3b8 100644 --- a/src/Orchard/Mvc/ModelBinders/BooleanBinderProvider.cs +++ b/src/Orchard/Mvc/ModelBinders/BooleanBinderProvider.cs @@ -16,6 +16,7 @@ namespace Orchard.Mvc.ModelBinders { public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var value = false; + if (string.IsNullOrWhiteSpace(controllerContext.HttpContext.Request[bindingContext.ModelName])) return false; var requestBooleanValue = controllerContext.HttpContext.Request[bindingContext.ModelName].Split(',')[0]; //Html.CheckBox and Html.CheckBoxFor return "true,false" string if (!bool.TryParse(requestBooleanValue, out value)) { bindingContext.ModelState.AddModelError(bindingContext.ModelName, new FormatException());