Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ public Task BindModelAsync(ModelBindingContext bindingContext)
// Other than the StringConverter, converters Trim() the value then throw if the result is empty.
model = null;
}
else if (bindingContext.ModelMetadata.IsNullableValueType && value == "null")
{
// Fix: This handles the issue where a URL parameter like `?age=null` cannot be bound to an `int?` type.
// This fix ensures that when the frontend sends a URL parameter with `null` value (e.g., `new URLSearchParams({ age: null }).toString()`),
// it correctly binds to a nullable integer (`int?`) instead of causing a binding error.
model = null;
}
else
{
model = _typeConverter.ConvertFrom(
Expand Down
Loading