Parameters binding removes whitespace
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Describe the bug
Binding parameters of controller methods to HTTP request values e.g. using the `[FromForm]` attribute results in `null` value when the value contains whitespace only.
### To Reproduce
```csharp
[HttpPost]
public IActionResult Post([FromForm] string text = null) { ... }
```
```
POST http://localhost:53777/post HTTP/1.1
Content-Type: application/x-www-form-urlencoded
text=%E2%80%AF
```
(i.e. the value is U+202F Narrow No-Break Space)
**Actual:** The `Post` method is called with `text` being `null`.
**Expected:** The `Post` method is called with `text` being `"\u202f"`, corresponding to the `Request.Form["text"]` value.
The same happens with mapping GET parameters and `Request.Query["text"]`. If this is by design, is there a way to turn it off?
### Further technical details
.NET SDKs installed:
2.2.207 [C:\Program Files\dotnet\sdk]
5.0.200-preview.20614.14 [C:\Program Files\dotnet\sdk]
ASP.NET Core version: 2.2
Visual Studio 16.9.0 Preview 3.0
Contributor guide
Assessment
This issue has not been assessed yet.