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