Microsoft.AspNetCore.TestHost 10.0.7
About
Microsoft.AspNetCore.TestHost provides an ASP.NET Core web server for testing middleware in isolation.
Key Features
- Instantiate an app pipeline containing only the components that you need to test
- Send custom requests to verify middleware behavior
How to Use
To use Microsoft.AspNetCore.TestHost, follow these steps:
Installation
dotnet add package Microsoft.AspNetCore.TestHost
Usage
To set up the TestServer, configure it in your test project. Here's an example:
[Fact]
public async Task MiddlewareTest_ReturnsNotFoundForRequest()
{
// Build and start a host that uses TestServer
using var host = await new HostBuilder()
.ConfigureWebHost(builder =>
{
builder.UseTestServer()
.ConfigureServices(services =>
{
// Add any required services that the middleware uses
services.AddMyServices();
})
.Configure(app =>
{
// Configure the processing pipeline to use the middleware
// for the test
app.UseMiddleware<MyMiddleware>();
});
})
.StartAsync();
var response = await host.GetTestClient().GetAsync("/");
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}
Main Types
The main types provided by this package are:
TestServer: AnIServerimplementation for executing testsTestServerOptions: Provides options for configuring aTestServer
Additional Documentation
For additional documentation and examples, refer to the official documentation for testing middleware in ASP.NET Core.
Feedback & Contributing
Microsoft.AspNetCore.TestHost is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Showing the top 20 packages that depend on Microsoft.AspNetCore.TestHost.
| Packages | Downloads |
|---|---|
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
109 |
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
111 |
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
112 |
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
113 |
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
114 |
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
116 |
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
117 |
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
118 |
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
120 |
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
122 |
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
128 |
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
130 |
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
133 |
|
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
|
110 |
|
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
|
113 |
|
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
|
116 |
|
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
|
123 |
.NET 10.0
- No dependencies.
| Version | Downloads | Last updated |
|---|---|---|
| 11.0.0-preview.3.26207.106 | 4 | 04/14/2026 |
| 11.0.0-preview.2.26159.112 | 13 | 03/10/2026 |
| 11.0.0-preview.1.26104.118 | 14 | 02/11/2026 |
| 10.0.7 | 2 | 04/21/2026 |
| 10.0.6 | 4 | 04/14/2026 |
| 10.0.5 | 14 | 03/14/2026 |
| 10.0.4 | 12 | 03/10/2026 |
| 10.0.3 | 20 | 02/11/2026 |
| 10.0.2 | 21 | 01/17/2026 |
| 10.0.1 | 41 | 12/14/2025 |
| 10.0.0 | 45 | 11/12/2025 |
| 10.0.0-rc.2.25502.107 | 60 | 10/15/2025 |
| 10.0.0-rc.1.25451.107 | 61 | 09/09/2025 |
| 10.0.0-preview.7.25380.108 | 67 | 08/14/2025 |
| 10.0.0-preview.6.25358.103 | 62 | 07/16/2025 |
| 10.0.0-preview.5.25277.114 | 96 | 06/07/2025 |
| 10.0.0-preview.4.25258.110 | 81 | 05/15/2025 |
| 10.0.0-preview.3.25172.1 | 83 | 04/14/2025 |
| 10.0.0-preview.2.25164.1 | 107 | 04/02/2025 |
| 10.0.0-preview.1.25120.3 | 91 | 04/02/2025 |
| 9.0.15 | 5 | 04/14/2026 |
| 9.0.14 | 14 | 03/10/2026 |
| 9.0.13 | 14 | 02/11/2026 |
| 9.0.12 | 18 | 01/17/2026 |
| 9.0.11 | 43 | 11/13/2025 |
| 9.0.10 | 53 | 10/15/2025 |
| 9.0.9 | 70 | 09/09/2025 |
| 9.0.8 | 79 | 08/06/2025 |
| 9.0.7 | 81 | 07/09/2025 |
| 9.0.6 | 85 | 06/12/2025 |
| 9.0.5 | 83 | 05/15/2025 |
| 9.0.4 | 96 | 04/10/2025 |
| 9.0.3 | 100 | 04/01/2025 |
| 9.0.2 | 112 | 04/01/2025 |
| 9.0.1 | 104 | 04/01/2025 |
| 9.0.0 | 106 | 11/15/2024 |
| 9.0.0-rc.2.24474.3 | 97 | 10/15/2024 |
| 9.0.0-rc.1.24452.1 | 100 | 10/05/2024 |
| 9.0.0-preview.7.24406.2 | 103 | 08/21/2024 |
| 9.0.0-preview.6.24328.4 | 91 | 07/21/2024 |
| 9.0.0-preview.5.24306.11 | 128 | 07/21/2024 |
| 9.0.0-preview.4.24267.6 | 138 | 07/21/2024 |
| 9.0.0-preview.3.24172.13 | 149 | 07/21/2024 |
| 9.0.0-preview.2.24128.4 | 114 | 07/21/2024 |
| 9.0.0-preview.1.24081.5 | 123 | 07/21/2024 |
| 8.0.26 | 5 | 04/14/2026 |
| 8.0.25 | 14 | 03/10/2026 |
| 8.0.24 | 16 | 02/11/2026 |
| 8.0.23 | 23 | 01/13/2026 |
| 8.0.22 | 60 | 11/13/2025 |
| 8.0.21 | 61 | 10/15/2025 |
| 8.0.20 | 68 | 09/09/2025 |
| 8.0.19 | 73 | 08/06/2025 |
| 8.0.18 | 74 | 07/09/2025 |
| 8.0.17 | 76 | 06/12/2025 |
| 8.0.16 | 70 | 05/15/2025 |
| 8.0.15 | 129 | 04/10/2025 |
| 8.0.14 | 94 | 04/01/2025 |
| 8.0.13 | 91 | 04/01/2025 |
| 8.0.12 | 112 | 04/01/2025 |
| 8.0.11 | 88 | 11/15/2024 |
| 8.0.10 | 92 | 10/14/2024 |
| 8.0.8 | 100 | 08/21/2024 |
| 8.0.7 | 108 | 07/21/2024 |
| 8.0.6 | 103 | 07/21/2024 |
| 8.0.5 | 108 | 07/21/2024 |
| 8.0.4 | 117 | 07/21/2024 |
| 8.0.3 | 97 | 07/21/2024 |
| 8.0.2 | 115 | 07/21/2024 |
| 8.0.1 | 130 | 07/21/2024 |
| 8.0.0 | 111 | 07/21/2024 |
| 8.0.0-rc.2.23480.2 | 116 | 07/21/2024 |
| 8.0.0-rc.1.23421.29 | 119 | 07/21/2024 |
| 8.0.0-preview.7.23375.9 | 123 | 07/21/2024 |
| 8.0.0-preview.6.23329.11 | 135 | 07/21/2024 |
| 8.0.0-preview.5.23302.2 | 123 | 07/21/2024 |
| 8.0.0-preview.4.23260.4 | 111 | 07/21/2024 |
| 8.0.0-preview.3.23177.8 | 120 | 07/21/2024 |
| 8.0.0-preview.2.23153.2 | 108 | 07/21/2024 |
| 8.0.0-preview.1.23112.2 | 125 | 07/21/2024 |
| 7.0.20 | 106 | 07/21/2024 |
| 7.0.19 | 107 | 07/21/2024 |
| 7.0.18 | 100 | 07/21/2024 |
| 7.0.17 | 112 | 07/21/2024 |
| 7.0.16 | 109 | 07/21/2024 |
| 7.0.15 | 104 | 07/21/2024 |
| 7.0.14 | 105 | 07/21/2024 |
| 7.0.13 | 120 | 07/21/2024 |
| 7.0.12 | 130 | 07/21/2024 |
| 7.0.11 | 123 | 07/21/2024 |
| 7.0.10 | 113 | 07/21/2024 |
| 7.0.9 | 108 | 07/21/2024 |
| 7.0.8 | 129 | 07/21/2024 |
| 7.0.7 | 131 | 07/21/2024 |
| 7.0.5 | 122 | 07/21/2024 |
| 7.0.4 | 113 | 07/21/2024 |
| 7.0.3 | 118 | 07/21/2024 |
| 7.0.2 | 129 | 07/21/2024 |
| 7.0.1 | 120 | 07/21/2024 |
| 7.0.0 | 120 | 07/21/2024 |
| 7.0.0-rc.2.22476.2 | 122 | 07/21/2024 |
| 7.0.0-rc.1.22427.2 | 116 | 07/21/2024 |
| 7.0.0-preview.7.22376.6 | 105 | 07/21/2024 |
| 7.0.0-preview.6.22330.3 | 115 | 07/21/2024 |
| 7.0.0-preview.5.22303.8 | 117 | 07/21/2024 |
| 7.0.0-preview.4.22251.1 | 112 | 07/21/2024 |
| 7.0.0-preview.3.22178.4 | 112 | 07/21/2024 |
| 7.0.0-preview.2.22153.2 | 106 | 07/21/2024 |
| 7.0.0-preview.1.22109.13 | 104 | 07/21/2024 |
| 6.0.36 | 98 | 11/15/2024 |
| 6.0.35 | 92 | 10/21/2024 |
| 6.0.33 | 107 | 08/21/2024 |
| 6.0.32 | 137 | 07/21/2024 |
| 6.0.31 | 110 | 07/21/2024 |
| 6.0.30 | 133 | 07/21/2024 |
| 6.0.29 | 116 | 07/21/2024 |
| 6.0.28 | 108 | 07/21/2024 |
| 6.0.27 | 114 | 07/21/2024 |
| 6.0.26 | 112 | 07/21/2024 |
| 6.0.25 | 112 | 07/21/2024 |
| 6.0.24 | 120 | 07/21/2024 |
| 6.0.23 | 111 | 07/21/2024 |
| 6.0.22 | 141 | 07/21/2024 |
| 6.0.21 | 111 | 07/21/2024 |
| 6.0.20 | 116 | 07/21/2024 |
| 6.0.19 | 112 | 07/21/2024 |
| 6.0.18 | 114 | 07/21/2024 |
| 6.0.16 | 100 | 07/21/2024 |
| 6.0.15 | 113 | 07/21/2024 |
| 6.0.14 | 121 | 07/21/2024 |
| 6.0.13 | 115 | 07/21/2024 |
| 6.0.12 | 121 | 07/21/2024 |
| 6.0.11 | 125 | 07/21/2024 |
| 6.0.10 | 124 | 07/21/2024 |
| 6.0.9 | 118 | 07/21/2024 |
| 6.0.8 | 123 | 07/21/2024 |
| 6.0.7 | 135 | 07/21/2024 |
| 6.0.6 | 125 | 07/21/2024 |
| 6.0.5 | 140 | 07/21/2024 |
| 6.0.4 | 127 | 07/21/2024 |
| 6.0.3 | 120 | 07/21/2024 |
| 6.0.2 | 109 | 07/21/2024 |
| 6.0.1 | 112 | 07/21/2024 |
| 6.0.0 | 118 | 07/21/2024 |
| 6.0.0-rc.2.21480.10 | 118 | 07/21/2024 |
| 6.0.0-rc.1.21452.15 | 116 | 07/21/2024 |
| 6.0.0-preview.7.21378.6 | 98 | 07/21/2024 |
| 6.0.0-preview.6.21355.2 | 122 | 07/21/2024 |
| 6.0.0-preview.5.21301.17 | 108 | 07/21/2024 |
| 6.0.0-preview.4.21253.5 | 138 | 07/21/2024 |
| 6.0.0-preview.3.21201.13 | 118 | 07/21/2024 |
| 6.0.0-preview.2.21154.6 | 102 | 07/21/2024 |
| 6.0.0-preview.1.21103.6 | 134 | 07/21/2024 |
| 5.0.17 | 115 | 07/21/2024 |
| 5.0.16 | 104 | 07/21/2024 |
| 5.0.15 | 98 | 07/21/2024 |
| 5.0.14 | 122 | 07/21/2024 |
| 5.0.13 | 126 | 07/21/2024 |
| 5.0.12 | 113 | 07/21/2024 |
| 5.0.11 | 120 | 07/21/2024 |
| 5.0.10 | 103 | 07/21/2024 |
| 5.0.9 | 106 | 07/21/2024 |
| 5.0.8 | 124 | 07/21/2024 |
| 5.0.7 | 105 | 07/21/2024 |
| 5.0.6 | 105 | 07/21/2024 |
| 5.0.5 | 127 | 07/21/2024 |
| 5.0.4 | 117 | 07/21/2024 |
| 5.0.3 | 117 | 07/21/2024 |
| 5.0.2 | 111 | 07/21/2024 |
| 5.0.1 | 112 | 07/21/2024 |
| 5.0.0 | 137 | 07/21/2024 |
| 5.0.0-rc.2.20475.17 | 113 | 07/21/2024 |
| 5.0.0-rc.1.20451.17 | 105 | 07/21/2024 |
| 5.0.0-preview.8.20414.8 | 113 | 07/21/2024 |
| 5.0.0-preview.7.20365.19 | 102 | 07/21/2024 |
| 5.0.0-preview.6.20312.15 | 125 | 07/21/2024 |
| 5.0.0-preview.5.20279.2 | 106 | 07/21/2024 |
| 5.0.0-preview.4.20257.10 | 118 | 07/21/2024 |
| 5.0.0-preview.3.20215.14 | 124 | 07/21/2024 |
| 5.0.0-preview.2.20167.3 | 103 | 07/21/2024 |
| 5.0.0-preview.1.20124.5 | 111 | 07/21/2024 |
| 3.1.32 | 121 | 07/21/2024 |
| 3.1.31 | 105 | 07/21/2024 |
| 3.1.30 | 120 | 07/21/2024 |
| 3.1.29 | 103 | 07/21/2024 |
| 3.1.28 | 123 | 07/21/2024 |
| 3.1.27 | 106 | 07/21/2024 |
| 3.1.26 | 113 | 07/21/2024 |
| 3.1.25 | 134 | 07/21/2024 |
| 3.1.24 | 109 | 07/21/2024 |
| 3.1.23 | 117 | 07/21/2024 |
| 3.1.22 | 123 | 07/21/2024 |
| 3.1.21 | 117 | 07/21/2024 |
| 3.1.20 | 108 | 07/21/2024 |
| 3.1.19 | 107 | 07/21/2024 |
| 3.1.18 | 118 | 07/21/2024 |
| 3.1.17 | 132 | 07/21/2024 |
| 3.1.16 | 122 | 07/21/2024 |
| 3.1.15 | 98 | 07/21/2024 |
| 3.1.14 | 126 | 07/21/2024 |
| 3.1.13 | 104 | 07/21/2024 |
| 3.1.12 | 103 | 07/21/2024 |
| 3.1.11 | 122 | 07/21/2024 |
| 3.1.10 | 133 | 07/21/2024 |
| 3.1.9 | 118 | 07/21/2024 |
| 3.1.8 | 114 | 07/21/2024 |
| 3.1.7 | 113 | 07/21/2024 |
| 3.1.6 | 113 | 07/21/2024 |
| 3.1.5 | 112 | 07/21/2024 |
| 3.1.4 | 123 | 07/21/2024 |
| 3.1.3 | 119 | 07/21/2024 |
| 3.1.2 | 136 | 07/21/2024 |
| 3.1.1 | 121 | 07/21/2024 |
| 3.1.0 | 121 | 07/21/2024 |
| 3.1.0-preview3.19555.2 | 132 | 07/21/2024 |
| 3.1.0-preview2.19528.8 | 146 | 07/21/2024 |
| 3.1.0-preview1.19508.20 | 96 | 07/21/2024 |
| 3.0.3 | 111 | 07/21/2024 |
| 3.0.2 | 120 | 07/21/2024 |
| 3.0.0 | 146 | 07/21/2024 |
| 3.0.0-rc1.19457.4 | 105 | 07/21/2024 |
| 3.0.0-preview9.19424.4 | 112 | 07/21/2024 |
| 3.0.0-preview8.19405.7 | 115 | 07/21/2024 |
| 3.0.0-preview7.19365.7 | 113 | 07/21/2024 |
| 3.0.0-preview6.19307.2 | 110 | 07/21/2024 |
| 3.0.0-preview5-19227-01 | 123 | 07/21/2024 |
| 3.0.0-preview4-19216-03 | 121 | 07/21/2024 |
| 3.0.0-preview3-19153-02 | 123 | 07/21/2024 |
| 3.0.0-preview-19075-0444 | 119 | 07/21/2024 |
| 3.0.0-preview-18579-0056 | 135 | 07/21/2024 |
| 2.3.9 | 21 | 01/07/2026 |
| 2.3.8 | 22 | 01/07/2026 |
| 2.3.0 | 90 | 04/01/2025 |
| 2.2.0 | 113 | 07/21/2024 |
| 2.2.0-preview3-35497 | 104 | 07/21/2024 |
| 2.2.0-preview2-35157 | 114 | 07/21/2024 |
| 2.2.0-preview1-35029 | 116 | 07/21/2024 |
| 2.1.1 | 108 | 07/21/2024 |
| 2.1.0 | 113 | 07/21/2024 |
| 2.1.0-rc1-final | 114 | 07/21/2024 |
| 2.1.0-preview2-final | 121 | 07/21/2024 |
| 2.1.0-preview1-final | 115 | 07/21/2024 |
| 2.0.3 | 113 | 07/21/2024 |
| 2.0.2 | 123 | 07/21/2024 |
| 2.0.1 | 116 | 07/21/2024 |
| 2.0.0 | 120 | 07/21/2024 |
| 2.0.0-preview2-final | 113 | 07/21/2024 |
| 2.0.0-preview1-final | 121 | 07/21/2024 |
| 1.1.3 | 134 | 07/21/2024 |
| 1.1.2 | 127 | 07/21/2024 |
| 1.1.1 | 138 | 07/21/2024 |
| 1.1.0 | 127 | 07/21/2024 |
| 1.1.0-preview1-final | 106 | 07/21/2024 |
| 1.0.5 | 128 | 07/21/2024 |
| 1.0.4 | 114 | 07/21/2024 |
| 1.0.3 | 96 | 07/21/2024 |
| 1.0.2 | 105 | 07/21/2024 |
| 1.0.1 | 116 | 07/21/2024 |
| 1.0.0 | 117 | 07/21/2024 |
| 1.0.0-rc2-final | 108 | 07/21/2024 |