-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Open
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
hi I found that the minimal Api TypedResults method does not automatically inject HttpContext.
The httpcontext principle is here in the reference
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-7.0#binding-precedence
Expected Behavior
The TypedResults method can automatically inject HttpContext.
Steps To Reproduce
File:Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.MapGroup("/connect").MapConnect();
app.Run();
File:Connect.cs
public static class Connect
{
public static RouteGroupBuilder MapConnect(this RouteGroupBuilder group)
{
group.MapGet("/authorize", AuthorizeAsync);
group.MapGet("/GoodMinimalApi", GoodMinimalApi);
return group;
}
public static async Task<IResult> GoodMinimalApi() // not HttpContext
{
await Task.CompletedTask;
return TypedResults.Ok();
}
public static async Task<IResult> AuthorizeAsync(HttpContext context)
{
await Task.CompletedTask;
return TypedResults.Ok();
}
}
End result
Exceptions (if any)
No response
.NET Version
dotnet 7.0
Anything else?
Microsoft Visual Studio Enterprise 2022 (64 位) - Current版本 17.4.0
ASP.NET Core 7
Minimal Api
swimmesberger
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi