Skip to content

Commit ce292b3

Browse files
authored
Set WebApplication.New().ServerFeatures (#40183)
1 parent a5e9e0f commit ce292b3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/DefaultBuilder/src/WebApplication.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public sealed class WebApplication : IHost, IApplicationBuilder, IEndpointRouteB
2727
internal WebApplication(IHost host)
2828
{
2929
_host = host;
30-
ApplicationBuilder = new ApplicationBuilder(host.Services);
30+
ApplicationBuilder = new ApplicationBuilder(host.Services, ServerFeatures);
3131
Logger = host.Services.GetRequiredService<ILoggerFactory>().CreateLogger(Environment.ApplicationName);
3232

3333
Properties[GlobalEndpointRouteBuilderKey] = this;

src/DefaultBuilder/test/Microsoft.AspNetCore.Tests/WebApplicationTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ namespace Microsoft.AspNetCore.Tests;
3131

3232
public class WebApplicationTests
3333
{
34+
[Fact]
35+
public async Task WebApplicationBuilder_New()
36+
{
37+
var builder = WebApplication.CreateBuilder(new string[] { "--urls", "http://localhost:5001" });
38+
39+
await using var app = builder.Build();
40+
var newApp = (app as IApplicationBuilder).New();
41+
Assert.NotNull(newApp.ServerFeatures);
42+
}
43+
3444
[Fact]
3545
public async Task WebApplicationBuilderConfiguration_IncludesCommandLineArguments()
3646
{

0 commit comments

Comments
 (0)