Skip to content

Support for route handler filters in minimal APIs issue #41188

Closed
@axzxs2001

Description

@axzxs2001

.net version is 7.0.100-preview.3.22179.4

The following code will work:

string SayHello(string name) => $"Hello, {name}!.";
app.MapGet("/hello/{name}", SayHello)
    .AddFilter(async (RouteHandlerInvocationContext context, RouteHandlerFilterDelegate next) =>
    {
        return await next(context);
    });

But the following code doesn't work:

app.MapGet("/hello/{name}", (string name) => $"Hello, {name}!.")
    .AddFilter(async (RouteHandlerInvocationContext context, RouteHandlerFilterDelegate next) =>
    {
        return await next(context);
    });

System.NullReferenceException:“Object reference not set to an instance of an object.”

Metadata

Metadata

Assignees

Labels

Priority:0Work that we can't release withoutbugThis issue describes a behavior which is not expected - a bug.old-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions