Microsoft.AspNetCore.TestHost 11.0.0-preview.7.26381.103

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
131
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
134
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
136
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
137
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
139
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
141
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
144
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
145
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
146
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
149
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
155
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
132
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
133
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
135
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
142
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
146

.NET 11.0

  • No dependencies.

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