Microsoft.AspNetCore.TestHost 10.0.2

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: An IServer implementation for executing tests
  • TestServerOptions: Provides options for configuring a TestServer

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
91
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
92
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
93
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
94
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
97
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
100
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
104
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
115
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
92
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
94
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
97
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
100
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
101

.NET 10.0

  • No dependencies.

Version Downloads Last updated
10.0.2 3 01/17/2026
10.0.1 14 12/14/2025
10.0.0 27 11/12/2025
10.0.0-rc.2.25502.107 44 10/15/2025
10.0.0-rc.1.25451.107 50 09/09/2025
10.0.0-preview.7.25380.108 55 08/14/2025
10.0.0-preview.6.25358.103 51 07/16/2025
10.0.0-preview.5.25277.114 73 06/07/2025
10.0.0-preview.4.25258.110 70 05/15/2025
10.0.0-preview.3.25172.1 67 04/14/2025
10.0.0-preview.2.25164.1 79 04/02/2025
10.0.0-preview.1.25120.3 78 04/02/2025
9.0.12 3 01/17/2026
9.0.11 27 11/13/2025
9.0.10 39 10/15/2025
9.0.9 54 09/09/2025
9.0.8 62 08/06/2025
9.0.7 65 07/09/2025
9.0.6 74 06/12/2025
9.0.5 66 05/15/2025
9.0.4 80 04/10/2025
9.0.3 81 04/01/2025
9.0.2 83 04/01/2025
9.0.1 84 04/01/2025
9.0.0 85 11/15/2024
9.0.0-rc.2.24474.3 83 10/15/2024
9.0.0-rc.1.24452.1 73 10/05/2024
9.0.0-preview.7.24406.2 86 08/21/2024
9.0.0-preview.6.24328.4 80 07/21/2024
9.0.0-preview.5.24306.11 108 07/21/2024
9.0.0-preview.4.24267.6 108 07/21/2024
9.0.0-preview.3.24172.13 114 07/21/2024
9.0.0-preview.2.24128.4 93 07/21/2024
9.0.0-preview.1.24081.5 102 07/21/2024
8.0.23 5 01/13/2026
8.0.22 34 11/13/2025
8.0.21 44 10/15/2025
8.0.20 48 09/09/2025
8.0.19 55 08/06/2025
8.0.18 56 07/09/2025
8.0.17 66 06/12/2025
8.0.16 53 05/15/2025
8.0.15 85 04/10/2025
8.0.14 76 04/01/2025
8.0.13 69 04/01/2025
8.0.12 84 04/01/2025
8.0.11 64 11/15/2024
8.0.10 79 10/14/2024
8.0.8 79 08/21/2024
8.0.7 94 07/21/2024
8.0.6 90 07/21/2024
8.0.5 89 07/21/2024
8.0.4 102 07/21/2024
8.0.3 85 07/21/2024
8.0.2 101 07/21/2024
8.0.1 109 07/21/2024
8.0.0 94 07/21/2024
8.0.0-rc.2.23480.2 102 07/21/2024
8.0.0-rc.1.23421.29 100 07/21/2024
8.0.0-preview.7.23375.9 101 07/21/2024
8.0.0-preview.6.23329.11 112 07/21/2024
8.0.0-preview.5.23302.2 106 07/21/2024
8.0.0-preview.4.23260.4 96 07/21/2024
8.0.0-preview.3.23177.8 107 07/21/2024
8.0.0-preview.2.23153.2 93 07/21/2024
8.0.0-preview.1.23112.2 92 07/21/2024
7.0.20 92 07/21/2024
7.0.19 89 07/21/2024
7.0.18 84 07/21/2024
7.0.17 92 07/21/2024
7.0.16 95 07/21/2024
7.0.15 88 07/21/2024
7.0.14 91 07/21/2024
7.0.13 104 07/21/2024
7.0.12 101 07/21/2024
7.0.11 105 07/21/2024
7.0.10 97 07/21/2024
7.0.9 93 07/21/2024
7.0.8 107 07/21/2024
7.0.7 105 07/21/2024
7.0.5 99 07/21/2024
7.0.4 100 07/21/2024
7.0.3 97 07/21/2024
7.0.2 98 07/21/2024
7.0.1 105 07/21/2024
7.0.0 99 07/21/2024
7.0.0-rc.2.22476.2 106 07/21/2024
7.0.0-rc.1.22427.2 97 07/21/2024
7.0.0-preview.7.22376.6 89 07/21/2024
7.0.0-preview.6.22330.3 100 07/21/2024
7.0.0-preview.5.22303.8 100 07/21/2024
7.0.0-preview.4.22251.1 95 07/21/2024
7.0.0-preview.3.22178.4 86 07/21/2024
7.0.0-preview.2.22153.2 94 07/21/2024
7.0.0-preview.1.22109.13 86 07/21/2024
6.0.36 79 11/15/2024
6.0.35 71 10/21/2024
6.0.33 68 08/21/2024
6.0.32 99 07/21/2024
6.0.31 98 07/21/2024
6.0.30 102 07/21/2024
6.0.29 94 07/21/2024
6.0.28 90 07/21/2024
6.0.27 94 07/21/2024
6.0.26 94 07/21/2024
6.0.25 98 07/21/2024
6.0.24 106 07/21/2024
6.0.23 96 07/21/2024
6.0.22 110 07/21/2024
6.0.21 93 07/21/2024
6.0.20 93 07/21/2024
6.0.19 91 07/21/2024
6.0.18 102 07/21/2024
6.0.16 87 07/21/2024
6.0.15 92 07/21/2024
6.0.14 106 07/21/2024
6.0.13 101 07/21/2024
6.0.12 105 07/21/2024
6.0.11 111 07/21/2024
6.0.10 105 07/21/2024
6.0.9 95 07/21/2024
6.0.8 96 07/21/2024
6.0.7 112 07/21/2024
6.0.6 102 07/21/2024
6.0.5 113 07/21/2024
6.0.4 105 07/21/2024
6.0.3 102 07/21/2024
6.0.2 94 07/21/2024
6.0.1 96 07/21/2024
6.0.0 101 07/21/2024
6.0.0-rc.2.21480.10 105 07/21/2024
6.0.0-rc.1.21452.15 104 07/21/2024
6.0.0-preview.7.21378.6 85 07/21/2024
6.0.0-preview.6.21355.2 101 07/21/2024
6.0.0-preview.5.21301.17 96 07/21/2024
6.0.0-preview.4.21253.5 122 07/21/2024
6.0.0-preview.3.21201.13 95 07/21/2024
6.0.0-preview.2.21154.6 90 07/21/2024
6.0.0-preview.1.21103.6 108 07/21/2024
5.0.17 95 07/21/2024
5.0.16 86 07/21/2024
5.0.15 82 07/21/2024
5.0.14 99 07/21/2024
5.0.13 100 07/21/2024
5.0.12 99 07/21/2024
5.0.11 101 07/21/2024
5.0.10 89 07/21/2024
5.0.9 91 07/21/2024
5.0.8 101 07/21/2024
5.0.7 90 07/21/2024
5.0.6 92 07/21/2024
5.0.5 103 07/21/2024
5.0.4 103 07/21/2024
5.0.3 99 07/21/2024
5.0.2 97 07/21/2024
5.0.1 98 07/21/2024
5.0.0 104 07/21/2024
5.0.0-rc.2.20475.17 99 07/21/2024
5.0.0-rc.1.20451.17 92 07/21/2024
5.0.0-preview.8.20414.8 101 07/21/2024
5.0.0-preview.7.20365.19 89 07/21/2024
5.0.0-preview.6.20312.15 108 07/21/2024
5.0.0-preview.5.20279.2 91 07/21/2024
5.0.0-preview.4.20257.10 104 07/21/2024
5.0.0-preview.3.20215.14 112 07/21/2024
5.0.0-preview.2.20167.3 84 07/21/2024
5.0.0-preview.1.20124.5 97 07/21/2024
3.1.32 105 07/21/2024
3.1.31 88 07/21/2024
3.1.30 105 07/21/2024
3.1.29 83 07/21/2024
3.1.28 103 07/21/2024
3.1.27 90 07/21/2024
3.1.26 94 07/21/2024
3.1.25 104 07/21/2024
3.1.24 90 07/21/2024
3.1.23 103 07/21/2024
3.1.22 106 07/21/2024
3.1.21 103 07/21/2024
3.1.20 91 07/21/2024
3.1.19 92 07/21/2024
3.1.18 92 07/21/2024
3.1.17 103 07/21/2024
3.1.16 103 07/21/2024
3.1.15 84 07/21/2024
3.1.14 104 07/21/2024
3.1.13 91 07/21/2024
3.1.12 85 07/21/2024
3.1.11 106 07/21/2024
3.1.10 115 07/21/2024
3.1.9 105 07/21/2024
3.1.8 102 07/21/2024
3.1.7 96 07/21/2024
3.1.6 101 07/21/2024
3.1.5 99 07/21/2024
3.1.4 92 07/21/2024
3.1.3 99 07/21/2024
3.1.2 106 07/21/2024
3.1.1 105 07/21/2024
3.1.0 101 07/21/2024
3.1.0-preview3.19555.2 115 07/21/2024
3.1.0-preview2.19528.8 91 07/21/2024
3.1.0-preview1.19508.20 81 07/21/2024
3.0.3 98 07/21/2024
3.0.2 104 07/21/2024
3.0.0 120 07/21/2024
3.0.0-rc1.19457.4 75 07/21/2024
3.0.0-preview9.19424.4 99 07/21/2024
3.0.0-preview8.19405.7 98 07/21/2024
3.0.0-preview7.19365.7 96 07/21/2024
3.0.0-preview6.19307.2 100 07/21/2024
3.0.0-preview5-19227-01 109 07/21/2024
3.0.0-preview4-19216-03 101 07/21/2024
3.0.0-preview3-19153-02 93 07/21/2024
3.0.0-preview-19075-0444 100 07/21/2024
3.0.0-preview-18579-0056 102 07/21/2024
2.3.9 7 01/07/2026
2.3.8 7 01/07/2026
2.3.0 73 04/01/2025
2.2.0 96 07/21/2024
2.2.0-preview3-35497 91 07/21/2024
2.2.0-preview2-35157 100 07/21/2024
2.2.0-preview1-35029 102 07/21/2024
2.1.1 90 07/21/2024
2.1.0 97 07/21/2024
2.1.0-rc1-final 99 07/21/2024
2.1.0-preview2-final 103 07/21/2024
2.1.0-preview1-final 99 07/21/2024
2.0.3 92 07/21/2024
2.0.2 106 07/21/2024
2.0.1 100 07/21/2024
2.0.0 98 07/21/2024
2.0.0-preview2-final 92 07/21/2024
2.0.0-preview1-final 103 07/21/2024
1.1.3 109 07/21/2024
1.1.2 107 07/21/2024
1.1.1 99 07/21/2024
1.1.0 91 07/21/2024
1.1.0-preview1-final 92 07/21/2024
1.0.5 105 07/21/2024
1.0.4 89 07/21/2024
1.0.3 81 07/21/2024
1.0.2 90 07/21/2024
1.0.1 101 07/21/2024
1.0.0 100 07/21/2024
1.0.0-rc2-final 94 07/21/2024