Cannot bind StringValues for HTTP request header with Minimal APIs
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
using `FromHeader` attribute on minimal API parameter with type `StringValues` type produce error on build and analyze
```
Program.cs(7,18,7,70): error ASP0020: Parameter 'ifMatch' of type StringValues should define a bool TryParse(string, IFormatProvider, out StringValues) method, or implement IParsable (https://aka.ms/aspnet/analyzers)
```
### Expected Behavior
_No response_
### Steps To Reproduce
build this code:
```csharp
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", ([FromHeader(Name = "If-Match")] StringValues ifMatch) => ifMatch);
app.Run();
```
### Exceptions (if any)
_No response_
### .NET Version
8.0.202
### Anything else?
there is an issue (#40752) that address same bug in previous versions. It seems it's returned again
Contributor guide
Assessment
This issue has not been assessed yet.