(Un)optimize binding because missing resolution for queries
This commit is contained in:
parent
45bc08897f
commit
5938879b98
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user