Microsoft.AspNetCore.TestHost 11.0.0

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
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications. This package was built from the source code at https://github.com/dotnet/dotnet/tree/b16286c2284fecf303dbc12a0bb152476d662e44
2,179
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
74
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
67
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
67
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
66
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
65
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
64
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
64
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/d9ba962869d1b1c410ea476b02de2f8e27eec762
63
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
63
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/25ef4aa38b77974263cb10f6e9cbd10135f17b59
63
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
63
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/568fff703254def7dcd35fda9892bf702d4c81d3
63

.NET 11.0

  • No dependencies.

Version Downloads Last updated
11.0.0 13 11/13/2026
11.0.0-rc.3.26522.148 20 10/25/2026
11.0.0-rc.2.26504.105 18 10/13/2026
11.0.0-rc.1.26425.128 24 09/10/2026
11.0.0-preview.7.26381.103 26 08/13/2026
11.0.0-preview.6.26359.118 30 07/17/2026
11.0.0-preview.5.26302.115 40 06/10/2026
11.0.0-preview.4.26230.115 39 05/14/2026
11.0.0-preview.3.26207.106 45 04/14/2026
11.0.0-preview.2.26159.112 48 03/14/2026
11.0.0-preview.1.26104.118 46 02/11/2026
10.0.15 11 11/15/2026
10.0.14 17 10/25/2026
10.0.13 20 10/13/2026
10.0.12 28 09/09/2026
10.0.11 27 08/13/2026
10.0.10 30 07/17/2026
10.0.9 25 06/10/2026
10.0.8 36 05/14/2026
10.0.7 2,194 04/23/2026
10.0.6 47 04/14/2026
10.0.5 45 03/14/2026
10.0.4 46 03/14/2026
10.0.3 49 02/12/2026
10.0.2 57 01/16/2026
10.0.1 60 12/11/2025
10.0.0 65 12/20/2025
10.0.0-rc.2.25502.107 49 12/20/2025
10.0.0-rc.1.25451.107 50 12/19/2025
10.0.0-preview.7.25380.108 45 12/12/2025
10.0.0-preview.6.25358.103 50 12/20/2025
10.0.0-preview.5.25277.114 51 12/16/2025
10.0.0-preview.4.25258.110 44 12/20/2025
10.0.0-preview.3.25172.1 46 12/14/2025
10.0.0-preview.2.25164.1 41 12/21/2025
10.0.0-preview.1.25120.3 42 12/12/2025
9.0.23 11 11/14/2026
9.0.22 18 10/25/2026
9.0.21 19 10/13/2026
9.0.20 21 09/09/2026
9.0.19 26 08/13/2026
9.0.18 21 07/17/2026
9.0.17 24 06/10/2026
9.0.16 28 05/14/2026
9.0.15 47 04/18/2026
9.0.14 48 03/14/2026
9.0.13 49 02/12/2026
9.0.12 57 01/18/2026
9.0.11 54 12/14/2025
9.0.10 57 12/17/2025
9.0.9 47 12/21/2025
9.0.8 48 12/25/2025
9.0.7 55 12/13/2025
9.0.6 54 12/13/2025
9.0.5 45 12/12/2025
9.0.4 40 12/16/2025
9.0.3 47 12/14/2025
9.0.2 47 01/01/2026
9.0.1 36 12/21/2025
9.0.0 44 01/10/2026
9.0.0-rc.2.24474.3 43 12/14/2025
9.0.0-rc.1.24452.1 40 12/21/2025
9.0.0-preview.7.24406.2 41 12/21/2025
9.0.0-preview.6.24328.4 43 12/16/2025
9.0.0-preview.5.24306.11 43 12/21/2025
9.0.0-preview.4.24267.6 42 12/21/2025
9.0.0-preview.3.24172.13 43 12/21/2025
9.0.0-preview.2.24128.4 47 12/14/2025
9.0.0-preview.1.24081.5 43 12/21/2025
8.0.34 14 11/14/2026
8.0.33 21 10/25/2026
8.0.32 19 10/13/2026
8.0.31 25 09/09/2026
8.0.30 26 08/13/2026
8.0.29 27 07/17/2026
8.0.28 28 06/10/2026
8.0.27 34 05/14/2026
8.0.26 49 04/14/2026
8.0.25 46 03/14/2026
8.0.24 58 02/12/2026
8.0.23 57 01/18/2026
8.0.22 48 12/20/2025
8.0.21 52 12/14/2025
8.0.20 50 12/18/2025
8.0.19 50 12/23/2025
8.0.18 54 12/13/2025
8.0.17 49 12/14/2025
8.0.16 48 12/14/2025
8.0.15 51 12/22/2025
8.0.14 52 12/18/2025
8.0.13 45 12/13/2025
8.0.12 44 01/10/2026
8.0.11 45 12/13/2025
8.0.10 46 12/11/2025
8.0.8 10 09/28/2026
8.0.7 58 12/26/2025
8.0.6 50 01/06/2026
8.0.5 44 12/13/2025
8.0.4 42 01/10/2026
8.0.3 41 12/19/2025
8.0.2 40 01/02/2026
8.0.1 46 12/13/2025
8.0.0 46 01/05/2026
8.0.0-rc.2.23480.2 42 12/21/2025
8.0.0-rc.1.23421.29 42 12/21/2025
8.0.0-preview.7.23375.9 43 12/21/2025
8.0.0-preview.6.23329.11 39 12/21/2025
8.0.0-preview.5.23302.2 37 12/21/2025
8.0.0-preview.4.23260.4 38 12/11/2025
8.0.0-preview.3.23177.8 38 12/21/2025
8.0.0-preview.2.23153.2 38 12/16/2025
8.0.0-preview.1.23112.2 41 12/13/2025
7.0.20 49 12/13/2025
7.0.19 45 01/04/2026
7.0.18 42 12/23/2025
7.0.17 45 12/12/2025
7.0.16 43 12/20/2025
7.0.15 45 12/14/2025
7.0.14 40 01/10/2026
7.0.13 8 10/02/2026
7.0.12 40 12/12/2025
7.0.11 42 12/14/2025
7.0.10 45 12/16/2025
7.0.9 40 12/14/2025
7.0.8 40 12/14/2025
7.0.7 43 12/16/2025
7.0.5 41 12/29/2025
7.0.4 45 12/13/2025
7.0.3 41 12/14/2025
7.0.2 46 12/14/2025
7.0.1 39 12/14/2025
7.0.0 11 09/30/2026
7.0.0-rc.2.22476.2 39 12/21/2025
7.0.0-rc.1.22427.2 44 12/21/2025
7.0.0-preview.7.22376.6 40 12/16/2025
7.0.0-preview.6.22330.3 10 09/28/2026
7.0.0-preview.5.22303.8 38 12/21/2025
7.0.0-preview.4.22251.1 42 12/21/2025
7.0.0-preview.3.22178.4 41 12/21/2025
7.0.0-preview.2.22153.2 41 12/21/2025
7.0.0-preview.1.22109.13 37 12/14/2025
6.0.36 50 01/08/2026
6.0.35 40 12/17/2025
6.0.33 44 01/10/2026
6.0.32 47 12/19/2025
6.0.31 47 01/10/2026
6.0.30 12 09/30/2026
6.0.29 43 12/29/2025
6.0.28 9 10/02/2026
6.0.27 51 12/11/2025
6.0.26 44 12/30/2025
6.0.25 9 10/09/2026
6.0.24 48 12/14/2025
6.0.23 47 12/13/2025
6.0.22 9 10/12/2026
6.0.21 38 12/23/2025
6.0.20 38 01/07/2026
6.0.19 41 01/02/2026
6.0.18 41 01/09/2026
6.0.16 43 12/13/2025
6.0.15 36 12/14/2025
6.0.14 48 12/14/2025
6.0.13 45 12/17/2025
6.0.12 42 12/14/2025
6.0.11 39 01/05/2026
6.0.10 43 12/13/2025
6.0.9 43 01/11/2026
6.0.8 44 12/18/2025
6.0.7 46 01/10/2026
6.0.6 49 01/05/2026
6.0.5 39 12/14/2025
6.0.4 42 01/10/2026
6.0.3 50 12/14/2025
6.0.2 36 01/10/2026
6.0.1 44 12/17/2025
6.0.0 46 01/05/2026
6.0.0-rc.2.21480.10 41 12/21/2025
6.0.0-rc.1.21452.15 41 12/21/2025
6.0.0-preview.7.21378.6 39 12/21/2025
6.0.0-preview.6.21355.2 41 12/16/2025
6.0.0-preview.5.21301.17 16 10/03/2026
6.0.0-preview.4.21253.5 42 12/19/2025
6.0.0-preview.3.21201.13 38 12/14/2025
6.0.0-preview.2.21154.6 38 12/14/2025
6.0.0-preview.1.21103.6 42 12/21/2025
5.0.17 45 01/07/2026
5.0.16 45 12/14/2025
5.0.15 11 09/29/2026
5.0.14 45 12/12/2025
5.0.13 38 12/28/2025
5.0.12 8 10/03/2026
5.0.11 48 12/21/2025
5.0.10 45 12/20/2025
5.0.9 41 12/29/2025
5.0.8 44 01/09/2026
5.0.7 48 12/18/2025
5.0.6 44 12/13/2025
5.0.5 41 12/26/2025
5.0.4 47 12/14/2025
5.0.3 48 01/10/2026
5.0.2 49 12/20/2025
5.0.1 44 01/05/2026
5.0.0 42 12/18/2025
5.0.0-rc.2.20475.17 43 12/21/2025
5.0.0-rc.1.20451.17 35 12/21/2025
5.0.0-preview.8.20414.8 38 12/14/2025
5.0.0-preview.7.20365.19 44 12/21/2025
5.0.0-preview.6.20312.15 40 12/19/2025
5.0.0-preview.5.20279.2 45 12/21/2025
5.0.0-preview.4.20257.10 42 12/21/2025
5.0.0-preview.3.20215.14 50 12/21/2025
5.0.0-preview.2.20167.3 42 12/21/2025
5.0.0-preview.1.20124.5 43 12/16/2025
3.1.32 43 12/17/2025
3.1.31 47 12/14/2025
3.1.30 51 12/22/2025
3.1.29 46 12/15/2025
3.1.28 47 12/15/2025
3.1.27 42 01/10/2026
3.1.26 46 01/07/2026
3.1.25 46 12/22/2025
3.1.24 50 12/12/2025
3.1.23 37 12/16/2025
3.1.22 41 12/20/2025
3.1.21 39 12/13/2025
3.1.20 40 01/10/2026
3.1.19 45 01/08/2026
3.1.18 44 01/05/2026
3.1.17 25 01/10/2026
3.1.16 43 12/21/2025
3.1.15 37 01/06/2026
3.1.14 42 12/29/2025
3.1.13 49 01/09/2026
3.1.12 49 12/13/2025
3.1.11 10 09/30/2026
3.1.10 46 01/09/2026
3.1.9 46 12/22/2025
3.1.8 40 12/20/2025
3.1.7 45 12/24/2025
3.1.6 43 01/06/2026
3.1.5 43 12/29/2025
3.1.4 46 12/22/2025
3.1.3 39 12/18/2025
3.1.2 40 12/15/2025
3.1.1 51 12/17/2025
3.1.0 44 12/23/2025
3.1.0-preview3.19555.2 41 12/19/2025
3.1.0-preview2.19528.8 41 12/20/2025
3.1.0-preview1.19508.20 43 01/07/2026
3.0.3 44 12/16/2025
3.0.2 47 12/14/2025
3.0.0 42 12/14/2025
3.0.0-rc1.19457.4 51 12/11/2025
3.0.0-preview9.19424.4 48 12/20/2025
3.0.0-preview8.19405.7 36 12/21/2025
3.0.0-preview7.19365.7 43 12/20/2025
3.0.0-preview6.19307.2 69 12/20/2025
3.0.0-preview5-19227-01 53 12/16/2025
3.0.0-preview4-19216-03 41 12/16/2025
3.0.0-preview3-19153-02 44 01/10/2026
3.0.0-preview-19075-0444 46 12/16/2025
3.0.0-preview-18579-0056 44 01/10/2026
2.3.14 11 11/13/2026
2.3.13 24 09/12/2026
2.3.12 25 08/13/2026
2.3.11 27 06/10/2026
2.3.10 35 05/14/2026
2.3.9 55 01/08/2026
2.3.8 56 01/07/2026
2.3.0 40 01/10/2026
2.2.0 46 01/03/2026
2.2.0-preview3-35497 40 12/21/2025
2.2.0-preview2-35157 9 09/30/2026
2.2.0-preview1-35029 44 12/14/2025
2.1.1 46 12/14/2025
2.1.0 42 01/10/2026
2.1.0-rc1-final 52 12/20/2025
2.1.0-preview2-final 46 12/14/2025
2.1.0-preview1-final 53 12/21/2025
2.0.3 54 12/20/2025
2.0.2 46 12/29/2025
2.0.1 45 12/20/2025
2.0.0 45 12/23/2025
2.0.0-preview2-final 48 12/21/2025
2.0.0-preview1-final 57 12/13/2025
1.1.3 44 12/29/2025
1.1.2 49 12/12/2025
1.1.1 41 12/19/2025
1.1.0 49 01/01/2026
1.1.0-preview1-final 55 12/21/2025
1.0.5 41 12/14/2025
1.0.4 42 01/10/2026
1.0.3 49 12/17/2025
1.0.2 45 01/10/2026
1.0.1 39 12/22/2025
1.0.0 47 12/22/2025
1.0.0-rc2-final 45 12/20/2025