Skip to content

Commit b3dbb14

Browse files
[release/6.0] Set WebApplication.New().ServerFeatures. (#43001)
1 parent dfe5ab7 commit b3dbb14

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
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: 13 additions & 3 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
{
@@ -1696,13 +1706,13 @@ public void EmptyAppConfiguration()
16961706
createdDirectory = true;
16971707
Directory.CreateDirectory(wwwroot);
16981708
}
1699-
1709+
17001710
try
17011711
{
17021712
var builder = WebApplication.CreateBuilder();
1703-
1713+
17041714
builder.WebHost.ConfigureAppConfiguration((ctx, config) => { });
1705-
1715+
17061716
using var app = builder.Build();
17071717
var hostEnv = app.Services.GetRequiredService<Hosting.IWebHostEnvironment>();
17081718
Assert.Equal(wwwroot, hostEnv.WebRootPath);

0 commit comments

Comments
 (0)