[HttpGet("{id}")]public IActionResult GetById(byte[] id) should be BindingSource.Path
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
## Take the liberty to make two suggestions
1. Is it possible to hand over the model binding work of `[HttpGet("{id}")]public IActionResult GetById(byte[] id)` to `ByteArrayModelBinder` for binding.
I am trying to do
```
[HttpGet("{id}")]
public ActionResult GetById(byte[] id)
{
......
}
```
but The value of `ControllerContext.ActionDescriptor.Parameters[0].BindingInfo.BindingSource` is `BindingSource.Body`,Resulting in parameter binding using `BodyModelBinder`, and the binding fails. response http status 415.
I know `[FromRoute]byte[] id` will do the trick, but I'd like it to be like any other simple type. Because in `[HttpGet("{id}")]` it is already specifically defined to get the value from the path and bind it to the `id` parameter.
If adopted, make all [HttpXXX("{id}")] available as such.
2. In addition to supporting base64 strings in `ByteArrayModelBinder`, it should also support **URL-safe base64** and **hex strings**.
----
Added: The framework is asp.net core 6.0
Contributor guide
Assessment
This issue has not been assessed yet.