mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-11-24 16:53:10 +08:00
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)
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user