Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mark WebHostBuilder class as obsolete#62785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge17 commits intomain
base:main
Choose a base branch
Loading
fromcopilot/fix-33c08791-0d71-4418-a169-d65989144212
Draft
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
17 commits
Select commitHold shift + click to select a range
5102b25
Initial plan
CopilotJul 17, 2025
54f0cdd
Mark WebHostBuilder class as obsolete with placeholder message
CopilotJul 17, 2025
8c3f586
Update WebHostBuilder usage to HostBuilder pattern in four target files
CopilotJul 17, 2025
8869208
fixup
BrennanConroyJul 17, 2025
5407fb0
Address review feedback: Add pragma disables and update to HostBuilde…
CopilotJul 17, 2025
dd80d9c
Add pragma warning suppression for WebHost.cs and remove from WebHost…
CopilotJul 17, 2025
3f16853
Update TestServerTests.cs and HttpsConfigurationTests.cs to use HostB…
CopilotJul 17, 2025
d028735
test
BrennanConroyJul 17, 2025
95e6eaa
fix tests
BrennanConroyJul 18, 2025
194d366
Remove nowarn settings and start converting TestHost tests to HostBui…
CopilotJul 18, 2025
e87e383
Complete conversion of RequestBuilderTests, ClientHandlerTests, and W…
CopilotJul 18, 2025
bd4d52f
Start converting TestHost test files to HostBuilder pattern
CopilotJul 19, 2025
b146f4d
Complete conversion of HttpContextBuilderTests.cs to HostBuilder pattern
CopilotJul 19, 2025
2f609b9
Partial conversion of TestClientTests.cs and TestServerTests.cs to Ho…
CopilotJul 19, 2025
dfcad52
Complete TestHost test file WebHostBuilder conversion - added pragma …
CopilotJul 20, 2025
9134e94
startasync
BrennanConroyJul 21, 2025
f6c7ee3
convert
BrennanConroyJul 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Update WebHostBuilder usage to HostBuilder pattern in four target files
Co-authored-by: BrennanConroy <7574801+BrennanConroy@users.noreply.github.com>
  • Loading branch information
@Copilot@BrennanConroy
Copilot andBrennanConroy committedJul 17, 2025
commit8c3f586cb8cff48b90d372fef4b82671dfba4e18
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,8 +25,12 @@ public async Task WebhostLoadsKeyRingBeforeServerStarts()
.Returns(Mock.Of<IKeyRing>())
.Callback(() => tcs.TrySetResult());

var builder = new WebHostBuilder()
.UseStartup<TestStartup>()
var builder = new HostBuilder()
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder
.UseStartup<TestStartup>();
})
.ConfigureServices(s =>
s.AddDataProtection()
.Services
Expand Down
86 changes: 55 additions & 31 deletionssrc/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,9 +56,13 @@
return 12;
case "HangOnStop":
{
var host = new WebHostBuilder()
.UseIIS()
.UseStartup<Startup>()
var host = new HostBuilder()

Check failure on line 59 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-quarantined-pr (Tests: macOS)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L59

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(59,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 59 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-quarantined-pr (Tests: Ubuntu x64)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L59

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(59,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 59 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-ci (Build Test: Ubuntu x64)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L59

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(59,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 59 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-ci (Build Test: macOS)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L59

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(59,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 59 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-quarantined-pr

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L59

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(59,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder
.UseIIS()
.UseStartup<Startup>();
})
.Build();
host.Run();

Expand All@@ -67,10 +71,14 @@
break;
case "IncreaseShutdownLimit":
{
var host = new WebHostBuilder()
.UseIIS()
.UseShutdownTimeout(TimeSpan.FromSeconds(120))
.UseStartup<Startup>()
var host = new HostBuilder()

Check failure on line 74 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-quarantined-pr (Tests: macOS)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L74

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(74,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 74 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-quarantined-pr (Tests: Ubuntu x64)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L74

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(74,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 74 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-ci (Build Test: Ubuntu x64)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L74

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(74,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 74 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-ci (Build Test: macOS)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L74

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(74,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 74 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-quarantined-pr

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L74

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(74,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder
.UseIIS()
.UseShutdownTimeout(TimeSpan.FromSeconds(120))
.UseStartup<Startup>();
})
.Build();

host.Run();
Expand All@@ -94,11 +102,15 @@
return 0;
case "OverriddenServer":
{
var host = new WebHostBuilder()
.UseIIS()
.ConfigureServices(services => services.AddSingleton<IServer, DummyServer>())
.Configure(builder => builder.Run(async context => { await context.Response.WriteAsync("I shouldn't work"); }))
.Build();
var host = new HostBuilder()

Check failure on line 105 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-quarantined-pr (Tests: macOS)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L105

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(105,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 105 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-quarantined-pr (Tests: Ubuntu x64)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L105

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(105,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 105 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-ci (Build Test: Ubuntu x64)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L105

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(105,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 105 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-ci (Build Test: macOS)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L105

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(105,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 105 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-quarantined-pr

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L105

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(105,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder
.UseIIS()
.ConfigureServices(services => services.AddSingleton<IServer, DummyServer>())
.Configure(builder => builder.Run(async context => { await context.Response.WriteAsync("I shouldn't work"); }));
})
.Build();
host.Run();
}
break;
Expand All@@ -111,18 +123,22 @@
#if !FORWARDCOMPAT
case "DecreaseRequestLimit":
{
var host = newWebHostBuilder()
var host = newHostBuilder()
.ConfigureLogging((_, factory) =>
{
factory.AddConsole();
factory.AddFilter("Console", level => level >= LogLevel.Information);
})
.UseIIS()
.ConfigureServices(services =>
.ConfigureWebHost(webHostBuilder =>
{
services.Configure<IISServerOptions>(options => options.MaxRequestBodySize = 2);
webHostBuilder
.UseIIS()
.ConfigureServices(services =>
{
services.Configure<IISServerOptions>(options => options.MaxRequestBodySize = 2);
})
.UseStartup<Startup>();
})
.UseStartup<Startup>()
.Build();

host.Run();
Expand All@@ -131,15 +147,19 @@
#endif
case "ThrowInStartup":
{
var host = new WebHostBuilder()
.ConfigureLogging((_, factory) =>
{
factory.AddConsole();
factory.AddFilter("Console", level => level >= LogLevel.Information);
})
.UseIIS()
.UseStartup<ThrowingStartup>()
.Build();
var host = new HostBuilder()

Check failure on line 150 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-quarantined-pr (Tests: macOS)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L150

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(150,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 150 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-quarantined-pr (Tests: Ubuntu x64)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L150

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(150,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 150 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-ci (Build Test: Ubuntu x64)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L150

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(150,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 150 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-ci (Build Test: macOS)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L150

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(150,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 150 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-quarantined-pr

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L150

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(150,36): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)
.ConfigureLogging((_, factory) =>
{
factory.AddConsole();
factory.AddFilter("Console", level => level >= LogLevel.Information);
})
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder
.UseIIS()
.UseStartup<ThrowingStartup>();
})
.Build();

host.Run();
}
Expand DownExpand Up@@ -189,16 +209,20 @@

private static int StartServer()
{
var host = newWebHostBuilder()
var host = newHostBuilder()

Check failure on line 212 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-quarantined-pr (Tests: macOS)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L212

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(212,24): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 212 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-ci (Build Test: Ubuntu x64)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L212

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(212,24): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 212 in src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs

View check run for this annotation

Azure Pipelines/ aspnetcore-ci (Build Test: macOS)

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs#L212

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Program.cs(212,24): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'HostBuilder' could not be found (are you missing a using directive or an assembly reference?)
.ConfigureLogging((_, factory) =>
{
factory.AddConsole();
factory.AddFilter("Console", level => level >= LogLevel.Information);
})
.UseKestrel()
.UseIIS()
.UseIISIntegration()
.UseStartup<Startup>()
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder
.UseKestrel()
.UseIIS()
.UseIISIntegration()
.UseStartup<Startup>();
})
.Build();

host.Run();
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -345,39 +345,43 @@ public async Task TlsHandshakeCallbackOptions_Invoked()
[InlineData(false, false, false)]
public async Task UseKestrelCore_CodeBased(bool useQuic, bool useHttps, bool useHttpsEnablesHttpsConfiguration)
{
var hostBuilder = new WebHostBuilder()
.UseKestrelCore()
.ConfigureKestrel(serverOptions =>
{
serverOptions.ListenAnyIP(0, listenOptions =>
var hostBuilder = new HostBuilder()
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder
.UseKestrelCore()
.ConfigureKestrel(serverOptions =>
{
listenOptions.Protocols = HttpProtocols.Http3;
if (useHttps)
serverOptions.ListenAnyIP(0, listenOptions =>
{
if (useHttpsEnablesHttpsConfiguration)
listenOptions.Protocols = HttpProtocols.Http3;
if (useHttps)
{
listenOptions.UseHttps(httpsOptions =>
if (useHttpsEnablesHttpsConfiguration)
{
httpsOptions.ServerCertificate = TestResources.GetTestCertificate();
});
}
else
{
// Specifically choose an overload that doesn't enable https configuration
listenOptions.UseHttps(new HttpsConnectionAdapterOptions
listenOptions.UseHttps(httpsOptions =>
{
httpsOptions.ServerCertificate = TestResources.GetTestCertificate();
});
}
else
{
ServerCertificate = TestResources.GetTestCertificate()
});
// Specifically choose an overload that doesn't enable https configuration
listenOptions.UseHttps(new HttpsConnectionAdapterOptions
{
ServerCertificate = TestResources.GetTestCertificate()
});
}
}
}
});
})
.Configure(app => { });
});
})
.Configure(app => { });

if (useQuic)
{
hostBuilder.UseQuic();
}
if (useQuic)
{
webHostBuilder.UseQuic();
}
});

var host = hostBuilder.Build();

Expand All@@ -400,25 +404,29 @@ public async Task UseKestrelCore_CodeBased(bool useQuic, bool useHttps, bool use
[InlineData(false)]
public void UseKestrelCore_ConfigurationBased(bool useQuic)
{
var hostBuilder = new WebHostBuilder()
.UseKestrelCore()
.ConfigureKestrel(serverOptions =>
{
var config = new ConfigurationBuilder().AddInMemoryCollection(new[]
var hostBuilder = new HostBuilder()
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder
.UseKestrelCore()
.ConfigureKestrel(serverOptions =>
{
new KeyValuePair<string, string>("Endpoints:end1:Url", "https://127.0.0.1:0"),
new KeyValuePair<string, string>("Endpoints:end1:Protocols", "Http3"),
new KeyValuePair<string, string>("Certificates:Default:Path", Path.Combine("shared", "TestCertificates", "aspnetdevcert.pfx")),
new KeyValuePair<string, string>("Certificates:Default:Password", "testPassword"),
}).Build();
serverOptions.Configure(config);
})
.Configure(app => { });

if (useQuic)
{
hostBuilder.UseQuic();
}
var config = new ConfigurationBuilder().AddInMemoryCollection(new[]
{
new KeyValuePair<string, string>("Endpoints:end1:Url", "https://127.0.0.1:0"),
new KeyValuePair<string, string>("Endpoints:end1:Protocols", "Http3"),
new KeyValuePair<string, string>("Certificates:Default:Path", Path.Combine("shared", "TestCertificates", "aspnetdevcert.pfx")),
new KeyValuePair<string, string>("Certificates:Default:Password", "testPassword"),
}).Build();
serverOptions.Configure(config);
})
.Configure(app => { });

if (useQuic)
{
webHostBuilder.UseQuic();
}
});

var host = hostBuilder.Build();

Expand Down
51 changes: 28 additions & 23 deletionssrc/Servers/testassets/ServerComparison.TestSites/Program.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,38 +13,43 @@ public static class Program
{
public static void Main(string[] args)
{
var builder = new WebHostBuilder()
.UseConfiguration(new ConfigurationBuilder()
.AddCommandLine(args)
.Build())
var configuration = new ConfigurationBuilder()
.AddCommandLine(args)
.Build();

var builder = new HostBuilder()
.UseConfiguration(configuration)
.ConfigureLogging((_, factory) =>
{
factory.AddConsole();
factory.AddFilter("Console", level => level >= LogLevel.Warning);
})
.UseStartup("ServerComparison.TestSites");

builder.UseKestrel();
builder.UseIISIntegration();
builder.UseIIS();

// Switch between Kestrel, IIS, and HttpSys for different tests. Default to Kestrel for normal app execution.
if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.HttpSys", StringComparison.OrdinalIgnoreCase))
{
builder.UseHttpSys(options =>
.ConfigureWebHost(webHostBuilder =>
{
if (string.Equals(builder.GetSetting("environment") ??
Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"),
"NtlmAuthentication", StringComparison.OrdinalIgnoreCase))
webHostBuilder
.UseStartup("ServerComparison.TestSites")
.UseKestrel()
.UseIISIntegration()
.UseIIS();

// Switch between Kestrel, IIS, and HttpSys for different tests. Default to Kestrel for normal app execution.
if (string.Equals(configuration["server"], "Microsoft.AspNetCore.Server.HttpSys", StringComparison.OrdinalIgnoreCase))
{
// Set up NTLM authentication for HttpSys as follows.
// For IIS and IISExpress use inetmgr to setup NTLM authentication on the application or
// modify the applicationHost.config to enable NTLM.
options.Authentication.AllowAnonymous = true;
options.Authentication.Schemes = AuthenticationSchemes.Negotiate | AuthenticationSchemes.NTLM;
webHostBuilder.UseHttpSys(options =>
{
if (string.Equals(configuration["environment"] ??
Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"),
"NtlmAuthentication", StringComparison.OrdinalIgnoreCase))
{
// Set up NTLM authentication for HttpSys as follows.
// For IIS and IISExpress use inetmgr to setup NTLM authentication on the application or
// modify the applicationHost.config to enable NTLM.
options.Authentication.AllowAnonymous = true;
options.Authentication.Schemes = AuthenticationSchemes.Negotiate | AuthenticationSchemes.NTLM;
}
});
}
});
}

var host = builder.Build();

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp