Microsoft.AspNetCore.TestHost 11.0.0-rc.1.26425.128

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/aspnet/AspNetCore/tree/62c098bc170f50feca15916e81cb7f321ffc52ff
21
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/bd1e14b7d16b798de8a874189c89afed755a266c
21
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
21
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/0a715692d8e2536c899faa0bb4f0cec2c2e33e36
22
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/1dcf7acfacf0fe154adcc23270cb0da11ff44ace
21
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/371a26f07b23ad77c636332c2dfc0cbd1d8137ba
21
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/3f1acb59718cadf111a0a796681e3d3509bb3381
22
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/4442a188f9200a57635373dcd640893c0e8dcc78
21
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/4e7d976438b0fc17f435804e801d5d68d193ec33
22
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/67acc3d331454956fc06d6de2218a625e3e596f8
21
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/68bb6fb08f8f85bb3cf08953a0d2f4a254eaccff
21
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/827b96040e62e5aa47d829bfa61c000d315d4f2e
22
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
21
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/ae2eabad0e49302d0632a7dde917fdc68d960dc4
21
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/b7a2ec8c7ed6b48857af0a69688a73e8c14fe6cb
21
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
21
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/d827c653b787c07de908240b7746ce34d3e6271e
22
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
21
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
21
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
21

.NET 11.0

  • No dependencies.

Version Downloads Last updated
11.0.0-rc.1.26425.128 1 12.09.2026
11.0.0-preview.7.26381.103 3 22.08.2026
11.0.0-preview.6.26359.118 3 21.07.2026
11.0.0-preview.5.26302.115 7 11.06.2026
11.0.0-preview.4.26230.115 6 20.05.2026
11.0.0-preview.3.26207.106 9 27.04.2026
11.0.0-preview.2.26159.112 6 14.03.2026
11.0.0-preview.1.26104.118 6 12.02.2026
10.0.12 1 12.09.2026
10.0.11 2 22.08.2026
10.0.10 3 21.07.2026
10.0.9 7 10.06.2026
10.0.8 8 20.05.2026
10.0.7 7 27.04.2026
10.0.6 9 27.04.2026
10.0.5 7 14.03.2026
10.0.4 6 14.03.2026
10.0.3 6 12.02.2026
10.0.2 8 22.01.2026
10.0.1 8 18.12.2025
10.0.0 9 18.12.2025
10.0.0-rc.2.25502.107 7 18.12.2025
10.0.0-rc.1.25451.107 8 18.12.2025
10.0.0-preview.7.25380.108 11 18.12.2025
10.0.0-preview.6.25358.103 8 06.08.2025
10.0.0-preview.5.25277.114 11 11.06.2025
10.0.0-preview.4.25258.110 12 11.06.2025
10.0.0-preview.3.25172.1 13 18.04.2025
10.0.0-preview.2.25164.1 13 14.04.2025
10.0.0-preview.1.25120.3 14 13.03.2025
9.0.20 1 12.09.2026
9.0.19 2 22.08.2026
9.0.18 3 21.07.2026
9.0.17 7 11.06.2026
9.0.16 8 20.05.2026
9.0.15 9 27.04.2026
9.0.14 8 14.03.2026
9.0.13 9 12.02.2026
9.0.12 8 22.01.2026
9.0.11 8 18.12.2025
9.0.10 9 18.12.2025
9.0.9 11 16.09.2025
9.0.8 11 16.09.2025
9.0.7 13 05.08.2025
9.0.6 13 28.06.2025
9.0.5 14 10.06.2025
9.0.4 17 25.04.2025
9.0.3 19 13.03.2025
9.0.2 18 18.02.2025
9.0.1 18 19.02.2025
9.0.0 17 19.02.2025
9.0.0-rc.2.24474.3 14 19.02.2025
9.0.0-rc.1.24452.1 14 19.02.2025
9.0.0-preview.7.24406.2 15 19.02.2025
9.0.0-preview.6.24328.4 14 19.02.2025
9.0.0-preview.5.24306.11 14 19.02.2025
9.0.0-preview.4.24267.6 15 20.02.2025
9.0.0-preview.3.24172.13 14 12.02.2025
9.0.0-preview.2.24128.4 15 19.02.2025
9.0.0-preview.1.24081.5 14 20.02.2025
8.0.31 1 12.09.2026
8.0.30 2 22.08.2026
8.0.29 3 21.07.2026
8.0.28 7 14.06.2026
8.0.27 9 20.05.2026
8.0.26 10 27.04.2026
8.0.25 7 14.03.2026
8.0.24 6 12.02.2026
8.0.23 7 22.01.2026
8.0.22 7 18.12.2025
8.0.21 9 18.12.2025
8.0.20 9 18.12.2025
8.0.19 8 18.12.2025
8.0.18 9 06.08.2025
8.0.17 10 29.06.2025
8.0.16 11 11.06.2025
8.0.15 13 17.04.2025
8.0.14 16 13.03.2025
8.0.13 15 22.02.2025
8.0.12 16 20.02.2025
8.0.11 15 19.02.2025
8.0.10 15 19.02.2025
8.0.8 19 19.02.2025
8.0.7 16 25.02.2025
8.0.6 18 19.02.2025
8.0.5 19 20.02.2025
8.0.4 18 19.02.2025
8.0.3 20 19.02.2025
8.0.2 18 20.02.2025
8.0.1 19 20.02.2025
8.0.0 19 19.02.2025
8.0.0-rc.2.23480.2 14 20.02.2025
8.0.0-rc.1.23421.29 14 25.02.2025
8.0.0-preview.7.23375.9 15 19.02.2025
8.0.0-preview.6.23329.11 17 19.02.2025
8.0.0-preview.5.23302.2 14 25.02.2025
8.0.0-preview.4.23260.4 15 19.02.2025
8.0.0-preview.3.23177.8 14 19.02.2025
8.0.0-preview.2.23153.2 14 19.02.2025
8.0.0-preview.1.23112.2 14 19.02.2025
7.0.20 17 01.03.2025
7.0.19 15 19.02.2025
7.0.18 15 19.02.2025
7.0.17 17 25.02.2025
7.0.16 15 20.02.2025
7.0.15 18 20.02.2025
7.0.14 16 25.02.2025
7.0.13 15 25.02.2025
7.0.12 14 20.02.2025
7.0.11 15 25.02.2025
7.0.10 15 26.02.2025
7.0.9 18 20.02.2025
7.0.8 18 18.02.2025
7.0.7 19 18.02.2025
7.0.5 17 19.02.2025
7.0.4 19 19.02.2025
7.0.3 17 19.02.2025
7.0.2 18 19.02.2025
7.0.1 18 20.02.2025
7.0.0 18 25.02.2025
7.0.0-rc.2.22476.2 14 25.02.2025
7.0.0-rc.1.22427.2 11 25.02.2025
7.0.0-preview.7.22376.6 14 19.02.2025
7.0.0-preview.6.22330.3 14 19.02.2025
7.0.0-preview.5.22303.8 16 25.02.2025
7.0.0-preview.4.22251.1 15 18.02.2025
7.0.0-preview.3.22178.4 14 25.02.2025
7.0.0-preview.2.22153.2 14 24.02.2025
7.0.0-preview.1.22109.13 14 20.02.2025
6.0.36 18 25.02.2025
6.0.35 15 28.02.2025
6.0.33 16 25.02.2025
6.0.32 15 22.02.2025
6.0.31 15 25.02.2025
6.0.30 15 25.02.2025
6.0.29 16 28.02.2025
6.0.28 15 19.02.2025
6.0.27 16 25.02.2025
6.0.26 15 01.03.2025
6.0.25 15 19.02.2025
6.0.24 15 25.02.2025
6.0.23 14 23.02.2025
6.0.22 15 19.02.2025
6.0.21 14 24.02.2025
6.0.20 15 23.02.2025
6.0.19 15 19.02.2025
6.0.18 15 25.02.2025
6.0.16 16 01.03.2025
6.0.15 17 25.02.2025
6.0.14 15 25.02.2025
6.0.13 15 23.02.2025
6.0.12 16 19.02.2025
6.0.11 15 20.02.2025
6.0.10 15 28.02.2025
6.0.9 19 21.02.2025
6.0.8 16 25.02.2025
6.0.7 19 24.02.2025
6.0.6 19 25.02.2025
6.0.5 19 25.02.2025
6.0.4 19 25.02.2025
6.0.3 18 18.02.2025
6.0.2 18 20.02.2025
6.0.1 17 25.02.2025
6.0.0 16 28.02.2025
6.0.0-rc.2.21480.10 14 25.02.2025
6.0.0-rc.1.21452.15 14 25.02.2025
6.0.0-preview.7.21378.6 14 20.02.2025
6.0.0-preview.6.21355.2 14 25.02.2025
6.0.0-preview.5.21301.17 14 25.02.2025
6.0.0-preview.4.21253.5 14 25.02.2025
6.0.0-preview.3.21201.13 14 16.02.2025
6.0.0-preview.2.21154.6 14 20.02.2025
6.0.0-preview.1.21103.6 14 16.02.2025
5.0.17 14 20.02.2025
5.0.16 15 23.02.2025
5.0.15 15 20.02.2025
5.0.14 15 20.02.2025
5.0.13 16 25.02.2025
5.0.12 15 19.02.2025
5.0.11 15 19.02.2025
5.0.10 16 16.02.2025
5.0.9 18 19.02.2025
5.0.8 18 19.02.2025
5.0.7 18 18.02.2025
5.0.6 18 19.02.2025
5.0.5 18 19.02.2025
5.0.4 15 13.03.2025
5.0.3 18 18.02.2025
5.0.2 18 12.02.2025
5.0.1 18 19.02.2025
5.0.0 18 20.02.2025
5.0.0-rc.2.20475.17 13 25.02.2025
5.0.0-rc.1.20451.17 14 24.02.2025
5.0.0-preview.8.20414.8 14 13.02.2025
5.0.0-preview.7.20365.19 14 19.02.2025
5.0.0-preview.6.20312.15 14 19.02.2025
5.0.0-preview.5.20279.2 14 25.02.2025
5.0.0-preview.4.20257.10 13 13.02.2025
5.0.0-preview.3.20215.14 14 20.02.2025
5.0.0-preview.2.20167.3 14 20.02.2025
5.0.0-preview.1.20124.5 14 19.02.2025
3.1.32 14 19.02.2025
3.1.31 15 19.02.2025
3.1.30 15 20.02.2025
3.1.29 18 19.02.2025
3.1.28 15 20.02.2025
3.1.27 14 19.02.2025
3.1.26 17 25.02.2025
3.1.25 15 20.02.2025
3.1.24 14 19.02.2025
3.1.23 15 20.02.2025
3.1.22 15 19.02.2025
3.1.21 14 24.02.2025
3.1.20 19 19.02.2025
3.1.19 16 19.02.2025
3.1.18 15 19.02.2025
3.1.17 15 19.02.2025
3.1.16 14 19.02.2025
3.1.15 15 18.02.2025
3.1.14 15 20.02.2025
3.1.13 16 23.02.2025
3.1.12 16 19.02.2025
3.1.11 16 19.02.2025
3.1.10 15 19.02.2025
3.1.9 18 19.02.2025
3.1.8 18 20.02.2025
3.1.7 18 13.02.2025
3.1.6 18 18.02.2025
3.1.5 18 19.02.2025
3.1.4 18 19.02.2025
3.1.3 19 19.02.2025
3.1.2 18 19.02.2025
3.1.1 17 19.02.2025
3.1.0 18 19.02.2025
3.1.0-preview3.19555.2 15 20.02.2025
3.1.0-preview2.19528.8 14 19.02.2025
3.1.0-preview1.19508.20 16 25.02.2025
3.0.3 18 19.02.2025
3.0.2 19 20.02.2025
3.0.0 17 18.02.2025
3.0.0-rc1.19457.4 19 25.02.2025
3.0.0-preview9.19424.4 15 25.02.2025
3.0.0-preview8.19405.7 14 19.02.2025
3.0.0-preview7.19365.7 14 18.02.2025
3.0.0-preview6.19307.2 16 25.02.2025
3.0.0-preview5-19227-01 14 25.02.2025
3.0.0-preview4-19216-03 15 25.02.2025
3.0.0-preview3-19153-02 15 20.02.2025
3.0.0-preview-19075-0444 14 25.02.2025
3.0.0-preview-18579-0056 14 25.02.2025
2.3.13 1 12.09.2026
2.3.12 2 21.08.2026
2.3.11 7 10.06.2026
2.3.10 9 20.05.2026
2.3.9 7 22.01.2026
2.3.8 7 22.01.2026
2.3.0 18 19.02.2025
2.2.0 18 16.02.2025
2.2.0-preview3-35497 15 20.02.2025
2.2.0-preview2-35157 14 12.02.2025
2.2.0-preview1-35029 14 01.03.2025
2.1.1 18 19.02.2025
2.1.0 18 15.02.2025
2.1.0-rc1-final 15 25.02.2025
2.1.0-preview2-final 15 13.02.2025
2.1.0-preview1-final 17 19.02.2025
2.0.3 18 19.02.2025
2.0.2 18 19.02.2025
2.0.1 18 19.02.2025
2.0.0 19 19.02.2025
2.0.0-preview2-final 15 13.02.2025
2.0.0-preview1-final 14 18.02.2025
1.1.3 18 20.02.2025
1.1.2 18 18.02.2025
1.1.1 17 20.02.2025
1.1.0 18 25.02.2025
1.1.0-preview1-final 18 20.02.2025
1.0.5 18 28.02.2025
1.0.4 18 20.02.2025
1.0.3 16 19.02.2025
1.0.2 18 25.02.2025
1.0.1 20 25.02.2025
1.0.0 18 25.02.2025
1.0.0-rc2-final 16 25.02.2025