dotnet / dotnet/aspnetcore

Difference between StringValue parameter handling in RDF and RDG

Open
#46,912 1 comment 0 reactions 0 assignees View on GitHub
area-minimal
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

The RDF does requiredness checks by comparing the value extracted from the HttpContext against `null`.

The RDG uses `StringValues.IsNullOrEmpty` to execute requiredness checks for values extract from the HttpContext as `StringValue`s (Header or Query). This results in distinct behavior between the RDF and RDG implementations:

| Handler | Query String | RDG | RDF |
|--|---|--|--|
| `(int p) => ..` | `?p=1` | Binds to 1 | Binds to 1 |
| `(int p) => ..` | `?p=` | Does not bind | Does not bind, throws failed to bind exception |
| `(int p) => ..` | none | Does not bind | Does not bind, throws requiredness exception |
| `(int? p) => ..` | `?p=1` | Binds to 1 | Binds to 1 |
| `(int? p) => ..` | `?p=` | Does not bind, defaults to null | Does not bind, throws failed to bind exception |
| `(int? p) => ..` | none | Does not bind, defaults to null | Does not bind, defaults to null |

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.