Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When calling the HttpContext.ApiVersioningFeature()
extension method and accessing IApiVerisoningFeature.RawRequestedApiVersions
, it is possible for infinite recursion to occur which causes StackOverflowException
.
Expected Behavior
No exception should occur.
Steps To Reproduce
var builder = WebApplication.CreateBuilder( args );
var app = builder.Build();
var values = app.NewVersionedApi();
var v1 = values.MapGroup("/values").HasApiVersion(1.0);
v1.MapGet("/", (HttpContext context) => {
// this will go through RawRequestedVersions and result in a stack overflow
var version = context.ApiVersioningFeature().RawRequestedVersion;
return Ok(new { message = $"{version} was requested." });
});
Note that
IServiceCollection.AddApiVersioning()
was not called
Exceptions (if any)
StackOverflowException
.NET Version
No response
Anything else?
No response