Microsoft.AspNetCore.TestHost 10.0.0-rc.2.25502.107

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/aspnetcore/tree/954f61dd38b33caa2b736c73530bd5a294174437
289
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/432e6a061f28dda696ba16bc5442328d23b25d93
75
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/d47e49e9c1e173ac90821f7e89cc38e710274241
75
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/ae1a6cbe225b99c0bf38b7e31bf60cb653b73a52
73
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications. This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/62c098bc170f50feca15916e81cb7f321ffc52ff
72
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications.
72
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/02c6de4ba6022025fcda7581415f310f8c73cdc3
72
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/bb01bbf4433e27289b99001b7de6a582879d1835
72
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/7c810658463f35c39c54d5fb8a8dbbfd463bf747
70
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/c911002ab43b7b989ed67090f2a48d9073d5118d
70
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
70
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/cdfa43bbe0ecc13757cc6517c9a253de77c3ec56
69
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications. This package was built from the source code at https://github.com/aspnet/Mvc/tree/a6199bbfbab05583f987bae322fb04566841aaea
68
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
68
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/e77cb01b5529c137130757859f09f892dbdd2436
67
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications.
66
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
66
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications. This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/844a82e37cae48af2ab2ee4f39b41283e6bb4f0e
65
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/cccab50fba1c7335fdb48a735246374b5ddd7e69
65

.NET 10.0

  • No dependencies.

Version Downloads Last updated
10.0.0-rc.2.25502.107 1 10/16/2025
10.0.0-rc.1.25451.107 6 09/11/2025
10.0.0-preview.7.25380.108 8 08/15/2025
10.0.0-preview.6.25358.103 13 07/17/2025
10.0.0-preview.5.25277.114 16 06/09/2025
10.0.0-preview.4.25258.110 18 05/15/2025
10.0.0-preview.3.25172.1 16 04/11/2025
10.0.0-preview.2.25164.1 21 03/22/2025
10.0.0-preview.1.25120.3 23 02/25/2025
9.0.10 1 10/16/2025
9.0.9 7 09/12/2025
9.0.8 11 08/07/2025
9.0.7 13 07/12/2025
9.0.6 15 06/12/2025
9.0.5 22 05/16/2025
9.0.4 17 04/11/2025
9.0.3 19 03/11/2025
9.0.2 23 02/15/2025
9.0.1 29 01/20/2025
9.0.0 33 11/13/2024
9.0.0-rc.2.24474.3 31 10/12/2024
9.0.0-rc.1.24452.1 36 09/17/2024
9.0.0-preview.7.24406.2 36 08/13/2024
9.0.0-preview.6.24328.4 40 07/10/2024
9.0.0-preview.5.24306.11 37 06/12/2024
9.0.0-preview.4.24267.6 42 06/06/2024
9.0.0-preview.3.24172.13 46 04/12/2024
9.0.0-preview.2.24128.4 49 03/17/2024
9.0.0-preview.1.24081.5 42 02/28/2024
8.0.21 1 10/16/2025
8.0.20 4 09/12/2025
8.0.19 11 08/07/2025
8.0.18 10 07/12/2025
8.0.17 14 06/12/2025
8.0.16 18 05/16/2025
8.0.15 20 04/11/2025
8.0.14 17 03/11/2025
8.0.13 22 02/14/2025
8.0.12 24 01/20/2025
8.0.11 30 11/13/2024
8.0.10 36 10/11/2024
8.0.8 289 08/13/2024
8.0.7 35 07/10/2024
8.0.6 34 06/11/2024
8.0.5 39 05/14/2024
8.0.4 47 04/12/2024
8.0.3 47 03/16/2024
8.0.2 47 03/03/2024
8.0.1 47 01/10/2024
8.0.0 49 11/17/2023
8.0.0-rc.2.23480.2 47 10/19/2023
8.0.0-rc.1.23421.29 45 09/14/2023
8.0.0-preview.7.23375.9 40 08/16/2023
8.0.0-preview.6.23329.11 44 08/04/2023
8.0.0-preview.5.23302.2 45 06/30/2023
8.0.0-preview.4.23260.4 38 07/01/2023
8.0.0-preview.3.23177.8 47 05/03/2023
8.0.0-preview.2.23153.2 41 05/03/2023
8.0.0-preview.1.23112.2 53 05/09/2023
7.0.20 39 06/11/2024
7.0.19 34 05/19/2024
7.0.18 35 04/12/2024
7.0.17 41 03/16/2024
7.0.16 48 03/03/2024
7.0.15 37 01/10/2024
7.0.14 44 11/17/2023
7.0.13 40 10/28/2023
7.0.12 51 10/11/2023
7.0.11 44 09/12/2023
7.0.10 56 08/18/2023
7.0.9 43 08/15/2023
7.0.8 44 08/07/2023
7.0.7 58 07/11/2023
7.0.5 47 05/03/2023
7.0.4 47 05/03/2023
7.0.3 56 05/03/2023
7.0.2 44 01/16/2023
7.0.1 58 04/20/2023
7.0.0 64 05/03/2023
7.0.0-rc.2.22476.2 40 07/04/2023
7.0.0-rc.1.22427.2 44 07/03/2023
7.0.0-preview.7.22376.6 52 06/28/2023
7.0.0-preview.6.22330.3 50 07/09/2023
7.0.0-preview.5.22303.8 47 07/02/2023
7.0.0-preview.4.22251.1 48 07/03/2023
7.0.0-preview.3.22178.4 61 10/08/2022
7.0.0-preview.2.22153.2 45 05/03/2023
7.0.0-preview.1.22109.13 73 05/09/2023
6.0.36 27 11/13/2024
6.0.35 30 10/18/2024
6.0.33 31 08/14/2024
6.0.32 36 07/10/2024
6.0.31 37 06/02/2024
6.0.30 42 05/19/2024
6.0.29 45 04/12/2024
6.0.28 39 03/16/2024
6.0.27 43 03/03/2024
6.0.26 42 01/10/2024
6.0.25 41 11/17/2023
6.0.24 42 10/28/2023
6.0.23 41 10/11/2023
6.0.22 41 09/12/2023
6.0.21 49 08/17/2023
6.0.20 43 08/08/2023
6.0.19 43 08/02/2023
6.0.18 44 08/21/2023
6.0.16 46 05/03/2023
6.0.15 48 05/03/2023
6.0.14 48 05/03/2023
6.0.13 46 05/09/2023
6.0.12 44 05/07/2023
6.0.11 48 03/21/2023
6.0.10 40 07/01/2023
6.0.9 46 04/27/2023
6.0.8 53 05/29/2023
6.0.7 45 07/06/2023
6.0.6 50 07/25/2022
6.0.5 46 07/04/2022
6.0.4 50 04/29/2023
6.0.3 46 06/30/2023
6.0.2 47 07/04/2023
6.0.1 50 12/15/2021
6.0.0 53 05/18/2023
6.0.0-rc.2.21480.10 46 07/01/2023
6.0.0-rc.1.21452.15 50 01/06/2023
6.0.0-preview.7.21378.6 54 07/02/2023
6.0.0-preview.6.21355.2 50 06/21/2023
6.0.0-preview.5.21301.17 43 07/21/2023
6.0.0-preview.4.21253.5 45 07/07/2023
6.0.0-preview.3.21201.13 44 07/09/2023
6.0.0-preview.2.21154.6 48 11/21/2022
6.0.0-preview.1.21103.6 46 03/18/2023
5.0.17 51 07/16/2022
5.0.16 49 04/22/2023
5.0.15 44 11/25/2022
5.0.14 43 07/04/2023
5.0.13 45 07/01/2023
5.0.12 41 05/09/2023
5.0.11 42 06/17/2023
5.0.10 45 05/09/2023
5.0.9 42 07/03/2023
5.0.8 57 05/09/2023
5.0.7 44 05/27/2022
5.0.6 47 07/03/2023
5.0.5 48 05/15/2023
5.0.4 49 09/11/2022
5.0.3 51 07/06/2023
5.0.2 46 05/17/2022
5.0.1 54 12/15/2021
5.0.0 47 07/07/2023
5.0.0-rc.2.20475.17 36 07/01/2023
5.0.0-rc.1.20451.17 51 07/02/2023
5.0.0-preview.8.20414.8 47 07/03/2023
5.0.0-preview.7.20365.19 50 11/09/2022
5.0.0-preview.6.20312.15 48 09/25/2022
5.0.0-preview.5.20279.2 51 05/16/2022
5.0.0-preview.4.20257.10 64 11/01/2022
5.0.0-preview.3.20215.14 42 07/11/2023
5.0.0-preview.2.20167.3 60 07/09/2023
5.0.0-preview.1.20124.5 57 11/14/2022
3.1.32 39 07/03/2023
3.1.31 46 05/09/2023
3.1.30 46 05/09/2023
3.1.29 38 07/02/2023
3.1.28 47 07/05/2023
3.1.27 44 07/02/2023
3.1.26 57 07/20/2022
3.1.25 47 10/21/2022
3.1.24 49 06/18/2023
3.1.23 47 06/03/2023
3.1.22 44 10/05/2022
3.1.21 54 07/19/2022
3.1.20 44 06/29/2023
3.1.19 45 07/04/2023
3.1.18 45 10/20/2022
3.1.17 43 07/04/2023
3.1.16 45 07/03/2023
3.1.15 51 07/02/2023
3.1.14 46 07/04/2023
3.1.13 46 05/03/2023
3.1.12 47 07/01/2023
3.1.11 56 09/24/2022
3.1.10 46 06/29/2023
3.1.9 54 07/05/2023
3.1.8 50 07/08/2023
3.1.7 44 07/01/2023
3.1.6 49 04/22/2023
3.1.5 47 04/26/2023
3.1.4 50 10/13/2022
3.1.3 45 04/19/2023
3.1.2 50 05/10/2023
3.1.1 55 09/28/2022
3.1.0 66 10/03/2022
3.1.0-preview3.19555.2 45 07/01/2023
3.1.0-preview2.19528.8 45 05/17/2022
3.1.0-preview1.19508.20 63 07/02/2023
3.0.3 51 04/17/2023
3.0.2 48 07/02/2023
3.0.0 49 07/03/2023
3.0.0-rc1.19457.4 45 07/01/2023
3.0.0-preview9.19424.4 48 07/12/2023
3.0.0-preview8.19405.7 49 10/07/2022
3.0.0-preview7.19365.7 45 07/01/2023
3.0.0-preview6.19307.2 44 11/06/2022
3.0.0-preview5-19227-01 45 11/06/2022
3.0.0-preview4-19216-03 48 07/01/2023
3.0.0-preview3-19153-02 43 11/23/2022
3.0.0-preview-19075-0444 48 07/03/2023
3.0.0-preview-18579-0056 35 10/13/2022
2.3.0 26 01/19/2025
2.2.0 46 04/29/2023
2.2.0-preview3-35497 48 07/06/2023
2.2.0-preview2-35157 42 05/09/2023
2.2.0-preview1-35029 55 06/06/2023
2.1.1 45 07/03/2023
2.1.0 54 10/14/2022
2.1.0-rc1-final 48 09/27/2022
2.1.0-preview2-final 54 07/01/2023
2.1.0-preview1-final 40 10/23/2022
2.0.3 47 07/08/2023
2.0.2 48 10/19/2022
2.0.1 49 07/04/2023
2.0.0 45 07/01/2023
2.0.0-preview2-final 46 05/09/2023
2.0.0-preview1-final 46 07/04/2023
1.1.3 51 05/06/2023
1.1.2 50 06/30/2023
1.1.1 49 05/09/2023
1.1.0 46 07/07/2023
1.1.0-preview1-final 48 07/01/2023
1.0.5 45 12/15/2021
1.0.4 44 12/15/2021
1.0.3 45 12/16/2022
1.0.2 41 07/03/2023
1.0.1 42 07/07/2023
1.0.0 52 12/15/2021
1.0.0-rc2-final 49 10/24/2022