You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Request with any api-version is handled by controller and there are no api-supported-versions header in response despite ReportApiVersions is set to true.
I used the Basic example with slight changes to reproduce the issue.
A successful status code is returned no matter which version is sent:
✔️ v1.0
❌ v2.0
❌ v9999
Expected Behavior
Request with unsupported version should return 4xx status code
The first problem is because TestController is not actually an API controller. It's missing [ApiController]. The attribute can also be applied on the entire assembly, but I don't see that and most people don't realize you can do that. Since TestController is not treated as an API controller, [ApiVersion] has no meaning; it's pure metadata. The apiVersion route constraint will allow any valid ApiVersion.
Reporting supported and deprecated API versions is dependent on getting to a candidate to use its metadata. Necessary changes in the routing policy may now eliminate candidates before there's any chance to retrieve metadata. This currently makes it impossible to report anything in some cases - mostly notably when something could exist, but doesn't. This change was needed to fix other issues related to 405, 406, and 415. This change was called out months ago in the roadmap and release notes. #876 is tracking a similar request. This is a difficult problem to solve. The only thing to go by in the request is the API version, but different APIs can have overlapping versions that don't necessarily have the version sets.
Since you're versioning by URL segment (the un-RESTful way), there was also a fix in Asp.Versioning.Http6.2.2 that addresses a scenario where you'll get 400 instead of 404. The URL is the identifier so if no API versions are detected in it, then it should be treated as 404.
Is there an existing issue for this?
Describe the bug
Request with any
api-version
is handled by controller and there are noapi-supported-versions
header in response despiteReportApiVersions
is set totrue
.I used the Basic example with slight changes to reproduce the issue.
A successful status code is returned no matter which version is sent:
✔️ v1.0
❌ v2.0
❌ v9999
Expected Behavior
Request with unsupported version should return 4xx status code
Steps To Reproduce
.csproj file
Program.cs
TestController.cs
Exceptions (if any)
No response
.NET Version
6.0.301
Anything else?
No response
The text was updated successfully, but these errors were encountered: