(Un)optimize binding because missing resolution for queries

This commit is contained in:
honzapatCZ 2026-09-13 15:59:12 +02:00
parent 45bc08897f
commit 5938879b98

View File

@ -100,17 +100,17 @@ namespace NejCommon.Models
? bindingContext.ModelName
: routeValue.Name;
var result = bindingContext.ValueProvider.GetValue(name);
// If these really are route values, don't go through the entire
// MVC ValueProvider infrastructure.
if (!bindingContext.ActionContext.RouteData.Values.TryGetValue(name, out var rawValue) ||
rawValue is null)
if (result == ValueProviderResult.None)
{
bindingContext.ModelState.AddModelError(name, "Route value not found");
bindingContext.Result = ModelBindingResult.Failed();
return;
}
values[i] = rawValue.ToString()!;
values[i] = result.FirstValue!;
}
// Check if all the required route values are present