Microsoft.AspNetCore.TestHost 11.0.0-preview.1.26104.118

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
102
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
105
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
106
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
107
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
110
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
117
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
119
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
124
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
102
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
105
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
108
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
114

.NET 11.0

  • No dependencies.

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