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/da7e9894ce22ef8cc02e5acc56e95a6f8cf8f644
47
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/70048beee894074e9718206a0017d9b080ee66ff
43
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/3fe12b935c03138f76364dc877a7e069e254b5b2
42
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/e5f183b656a0e8bc087108130a5a9b54ae94494e
42
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/aee5e4080331553ea9dfb7fb388b6d72f715bf6a
42
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/96103c264e5e8f0485d07018ba27b78cd8227dd2
41
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/1f050242559e7b90ff6c4ee7f99d92b3a5af5a62
41
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/1bf292d47ac2a0ebda07d8a3f00355dd01915ad5
40
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/c663adee8e64ba5d379fa0edfb8201984a7df7d0
40
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/dc5e11abdb05b322f4b74b3afbcfb352fe984b2e
40
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/e882394a7bb38930da748291fe2c2ceaa6a80588
40
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/fc93e595ceffbb1e3e85532bf454e92a6a80dd6b
40
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/2b7e994b8a304700a09617ffc5052f0d943bbcba
40
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/25bd01f17d5f01fc78bea5eb5308b2c0d79e2889
40
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/57512b49997283599b00a6b67d0ccebaec171daf
40
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/e3187077455f953200e3c930430808a30f48b82e
40
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/e56abc45c4f8adc518abfc11a59849d616431e2c
39
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
39
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/564969bca155b40432d101ec35f24a0e81e6afa0
39
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/32e8c8cae5b1a4dd752d0a42a6f8a2813f75f173
39

.NET 10.0

  • No dependencies.

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