Skip to content

WebApplication.New().ServerFeatures is null  #40042

@NGloreous

Description

@NGloreous

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When using minimal APIs in ASP.NET Core 6, after creating a new application from the existing app, the ServerFeatures property of the new application is null.

Per @Tratcher, this is because the ServerFeatures are never put in the property bag of the application:

internal IFeatureCollection ServerFeatures => _host.Services.GetRequiredService<IServer>().Features;
IFeatureCollection IApplicationBuilder.ServerFeatures => ServerFeatures;
.

Expected Behavior

ServerFeatures shouldn't be null.

Steps To Reproduce

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
var newApp = (app as IApplicationBuilder).New();
Debug.Assert(newApp.ServerFeatures != null);

Exceptions (if any)

No response

.NET Version

6.0.100

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsbugThis issue describes a behavior which is not expected - a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions