Microsoft.AspNetCore.TestHost 11.0.0-preview.5.26302.115

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
120
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
123
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
124
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
125
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
126
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
127
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
129
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
132
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
138
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
142
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
143
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
121
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
124
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
130
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
132

.NET 11.0

  • No dependencies.

Version Downloads Last updated
11.0.0-preview.5.26302.115 5 06/09/2026
11.0.0-preview.4.26230.115 8 05/13/2026
11.0.0-preview.3.26207.106 14 04/14/2026
11.0.0-preview.2.26159.112 22 03/10/2026
11.0.0-preview.1.26104.118 19 02/11/2026
10.0.9 4 06/09/2026
10.0.8 9 05/13/2026
10.0.7 16 04/21/2026
10.0.6 13 04/14/2026
10.0.5 24 03/14/2026
10.0.4 20 03/10/2026
10.0.3 25 02/11/2026
10.0.2 29 01/17/2026
10.0.1 47 12/14/2025
10.0.0 54 11/12/2025
10.0.0-rc.2.25502.107 69 10/15/2025
10.0.0-rc.1.25451.107 65 09/09/2025
10.0.0-preview.7.25380.108 72 08/14/2025
10.0.0-preview.6.25358.103 71 07/16/2025
10.0.0-preview.5.25277.114 103 06/07/2025
10.0.0-preview.4.25258.110 89 05/15/2025
10.0.0-preview.3.25172.1 90 04/14/2025
10.0.0-preview.2.25164.1 115 04/02/2025
10.0.0-preview.1.25120.3 100 04/02/2025
9.0.17 4 06/09/2026
9.0.16 10 05/13/2026
9.0.15 15 04/14/2026
9.0.14 19 03/10/2026
9.0.13 20 02/11/2026
9.0.12 29 01/17/2026
9.0.11 48 11/13/2025
9.0.10 65 10/15/2025
9.0.9 78 09/09/2025
9.0.8 87 08/06/2025
9.0.7 89 07/09/2025
9.0.6 92 06/12/2025
9.0.5 87 05/15/2025
9.0.4 103 04/10/2025
9.0.3 108 04/01/2025
9.0.2 121 04/01/2025
9.0.1 115 04/01/2025
9.0.0 111 11/15/2024
9.0.0-rc.2.24474.3 106 10/15/2024
9.0.0-rc.1.24452.1 107 10/05/2024
9.0.0-preview.7.24406.2 114 08/21/2024
9.0.0-preview.6.24328.4 99 07/21/2024
9.0.0-preview.5.24306.11 136 07/21/2024
9.0.0-preview.4.24267.6 145 07/21/2024
9.0.0-preview.3.24172.13 154 07/21/2024
9.0.0-preview.2.24128.4 123 07/21/2024
9.0.0-preview.1.24081.5 133 07/21/2024
8.0.28 5 06/09/2026
8.0.27 8 05/13/2026
8.0.26 12 04/14/2026
8.0.25 20 03/10/2026
8.0.24 26 02/11/2026
8.0.23 29 01/13/2026
8.0.22 72 11/13/2025
8.0.21 65 10/15/2025
8.0.20 75 09/09/2025
8.0.19 84 08/06/2025
8.0.18 79 07/09/2025
8.0.17 84 06/12/2025
8.0.16 74 05/15/2025
8.0.15 139 04/10/2025
8.0.14 102 04/01/2025
8.0.13 103 04/01/2025
8.0.12 118 04/01/2025
8.0.11 96 11/15/2024
8.0.10 97 10/14/2024
8.0.8 108 08/21/2024
8.0.7 120 07/21/2024
8.0.6 107 07/21/2024
8.0.5 116 07/21/2024
8.0.4 122 07/21/2024
8.0.3 104 07/21/2024
8.0.2 124 07/21/2024
8.0.1 136 07/21/2024
8.0.0 118 07/21/2024
8.0.0-rc.2.23480.2 125 07/21/2024
8.0.0-rc.1.23421.29 125 07/21/2024
8.0.0-preview.7.23375.9 137 07/21/2024
8.0.0-preview.6.23329.11 143 07/21/2024
8.0.0-preview.5.23302.2 130 07/21/2024
8.0.0-preview.4.23260.4 119 07/21/2024
8.0.0-preview.3.23177.8 134 07/21/2024
8.0.0-preview.2.23153.2 115 07/21/2024
8.0.0-preview.1.23112.2 135 07/21/2024
7.0.20 116 07/21/2024
7.0.19 116 07/21/2024
7.0.18 108 07/21/2024
7.0.17 119 07/21/2024
7.0.16 114 07/21/2024
7.0.15 112 07/21/2024
7.0.14 109 07/21/2024
7.0.13 127 07/21/2024
7.0.12 136 07/21/2024
7.0.11 130 07/21/2024
7.0.10 119 07/21/2024
7.0.9 117 07/21/2024
7.0.8 140 07/21/2024
7.0.7 136 07/21/2024
7.0.5 130 07/21/2024
7.0.4 117 07/21/2024
7.0.3 123 07/21/2024
7.0.2 143 07/21/2024
7.0.1 127 07/21/2024
7.0.0 126 07/21/2024
7.0.0-rc.2.22476.2 131 07/21/2024
7.0.0-rc.1.22427.2 121 07/21/2024
7.0.0-preview.7.22376.6 112 07/21/2024
7.0.0-preview.6.22330.3 121 07/21/2024
7.0.0-preview.5.22303.8 124 07/21/2024
7.0.0-preview.4.22251.1 119 07/21/2024
7.0.0-preview.3.22178.4 121 07/21/2024
7.0.0-preview.2.22153.2 112 07/21/2024
7.0.0-preview.1.22109.13 109 07/21/2024
6.0.36 106 11/15/2024
6.0.35 97 10/21/2024
6.0.33 115 08/21/2024
6.0.32 142 07/21/2024
6.0.31 120 07/21/2024
6.0.30 140 07/21/2024
6.0.29 123 07/21/2024
6.0.28 115 07/21/2024
6.0.27 120 07/21/2024
6.0.26 120 07/21/2024
6.0.25 118 07/21/2024
6.0.24 126 07/21/2024
6.0.23 117 07/21/2024
6.0.22 148 07/21/2024
6.0.21 116 07/21/2024
6.0.20 120 07/21/2024
6.0.19 117 07/21/2024
6.0.18 122 07/21/2024
6.0.16 106 07/21/2024
6.0.15 121 07/21/2024
6.0.14 128 07/21/2024
6.0.13 127 07/21/2024
6.0.12 127 07/21/2024
6.0.11 131 07/21/2024
6.0.10 131 07/21/2024
6.0.9 125 07/21/2024
6.0.8 135 07/21/2024
6.0.7 142 07/21/2024
6.0.6 136 07/21/2024
6.0.5 145 07/21/2024
6.0.4 135 07/21/2024
6.0.3 129 07/21/2024
6.0.2 117 07/21/2024
6.0.1 118 07/21/2024
6.0.0 124 07/21/2024
6.0.0-rc.2.21480.10 126 07/21/2024
6.0.0-rc.1.21452.15 121 07/21/2024
6.0.0-preview.7.21378.6 104 07/21/2024
6.0.0-preview.6.21355.2 130 07/21/2024
6.0.0-preview.5.21301.17 114 07/21/2024
6.0.0-preview.4.21253.5 147 07/21/2024
6.0.0-preview.3.21201.13 124 07/21/2024
6.0.0-preview.2.21154.6 110 07/21/2024
6.0.0-preview.1.21103.6 140 07/21/2024
5.0.17 122 07/21/2024
5.0.16 110 07/21/2024
5.0.15 104 07/21/2024
5.0.14 129 07/21/2024
5.0.13 132 07/21/2024
5.0.12 121 07/21/2024
5.0.11 127 07/21/2024
5.0.10 109 07/21/2024
5.0.9 114 07/21/2024
5.0.8 128 07/21/2024
5.0.7 108 07/21/2024
5.0.6 114 07/21/2024
5.0.5 132 07/21/2024
5.0.4 126 07/21/2024
5.0.3 121 07/21/2024
5.0.2 117 07/21/2024
5.0.1 120 07/21/2024
5.0.0 141 07/21/2024
5.0.0-rc.2.20475.17 117 07/21/2024
5.0.0-rc.1.20451.17 111 07/21/2024
5.0.0-preview.8.20414.8 119 07/21/2024
5.0.0-preview.7.20365.19 109 07/21/2024
5.0.0-preview.6.20312.15 129 07/21/2024
5.0.0-preview.5.20279.2 114 07/21/2024
5.0.0-preview.4.20257.10 125 07/21/2024
5.0.0-preview.3.20215.14 133 07/21/2024
5.0.0-preview.2.20167.3 110 07/21/2024
5.0.0-preview.1.20124.5 117 07/21/2024
3.1.32 127 07/21/2024
3.1.31 111 07/21/2024
3.1.30 125 07/21/2024
3.1.29 111 07/21/2024
3.1.28 131 07/21/2024
3.1.27 118 07/21/2024
3.1.26 118 07/21/2024
3.1.25 139 07/21/2024
3.1.24 118 07/21/2024
3.1.23 122 07/21/2024
3.1.22 129 07/21/2024
3.1.21 127 07/21/2024
3.1.20 118 07/21/2024
3.1.19 112 07/21/2024
3.1.18 123 07/21/2024
3.1.17 142 07/21/2024
3.1.16 129 07/21/2024
3.1.15 106 07/21/2024
3.1.14 132 07/21/2024
3.1.13 111 07/21/2024
3.1.12 107 07/21/2024
3.1.11 128 07/21/2024
3.1.10 141 07/21/2024
3.1.9 132 07/21/2024
3.1.8 120 07/21/2024
3.1.7 122 07/21/2024
3.1.6 120 07/21/2024
3.1.5 119 07/21/2024
3.1.4 130 07/21/2024
3.1.3 128 07/21/2024
3.1.2 145 07/21/2024
3.1.1 127 07/21/2024
3.1.0 132 07/21/2024
3.1.0-preview3.19555.2 141 07/21/2024
3.1.0-preview2.19528.8 153 07/21/2024
3.1.0-preview1.19508.20 103 07/21/2024
3.0.3 115 07/21/2024
3.0.2 127 07/21/2024
3.0.0 151 07/21/2024
3.0.0-rc1.19457.4 115 07/21/2024
3.0.0-preview9.19424.4 122 07/21/2024
3.0.0-preview8.19405.7 126 07/21/2024
3.0.0-preview7.19365.7 117 07/21/2024
3.0.0-preview6.19307.2 120 07/21/2024
3.0.0-preview5-19227-01 128 07/21/2024
3.0.0-preview4-19216-03 130 07/21/2024
3.0.0-preview3-19153-02 130 07/21/2024
3.0.0-preview-19075-0444 128 07/21/2024
3.0.0-preview-18579-0056 142 07/21/2024
2.3.11 5 06/09/2026
2.3.10 10 05/13/2026
2.3.9 26 01/07/2026
2.3.8 29 01/07/2026
2.3.0 97 04/01/2025
2.2.0 121 07/21/2024
2.2.0-preview3-35497 109 07/21/2024
2.2.0-preview2-35157 120 07/21/2024
2.2.0-preview1-35029 123 07/21/2024
2.1.1 116 07/21/2024
2.1.0 122 07/21/2024
2.1.0-rc1-final 118 07/21/2024
2.1.0-preview2-final 128 07/21/2024
2.1.0-preview1-final 122 07/21/2024
2.0.3 118 07/21/2024
2.0.2 128 07/21/2024
2.0.1 122 07/21/2024
2.0.0 128 07/21/2024
2.0.0-preview2-final 123 07/21/2024
2.0.0-preview1-final 129 07/21/2024
1.1.3 145 07/21/2024
1.1.2 138 07/21/2024
1.1.1 142 07/21/2024
1.1.0 134 07/21/2024
1.1.0-preview1-final 113 07/21/2024
1.0.5 134 07/21/2024
1.0.4 122 07/21/2024
1.0.3 106 07/21/2024
1.0.2 113 07/21/2024
1.0.1 123 07/21/2024
1.0.0 126 07/21/2024
1.0.0-rc2-final 119 07/21/2024