Microsoft.AspNetCore.TestHost 10.0.0-preview.4.25255.103

Prefix Reserved
This is a prerelease version of Microsoft.AspNetCore.TestHost.
dotnet add package Microsoft.AspNetCore.TestHost --version 10.0.0-preview.4.25255.103
                    
NuGet\Install-Package Microsoft.AspNetCore.TestHost -Version 10.0.0-preview.4.25255.103
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="10.0.0-preview.4.25255.103" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="10.0.0-preview.4.25255.103" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.AspNetCore.TestHost" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.AspNetCore.TestHost --version 10.0.0-preview.4.25255.103
                    
#r "nuget: Microsoft.AspNetCore.TestHost, 10.0.0-preview.4.25255.103"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Microsoft.AspNetCore.TestHost&version=10.0.0-preview.4.25255.103&prerelease
                    
Install Microsoft.AspNetCore.TestHost as a Cake Addin
#tool nuget:?package=Microsoft.AspNetCore.TestHost&version=10.0.0-preview.4.25255.103&prerelease
                    
Install Microsoft.AspNetCore.TestHost as a Cake Tool

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.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

GitHub repositories (217)

Showing the top 20 popular GitHub repositories that depend on Microsoft.AspNetCore.TestHost:

Repository Stars
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
aspnetboilerplate/aspnetboilerplate
ASP.NET Boilerplate - Web Application Framework
dotnet/yarp
A toolkit for developing high-performance HTTP reverse proxy applications.
ThreeMammals/Ocelot
.NET API Gateway
dotnet/eShop
A reference .NET application implementing an eCommerce site
RicoSuter/NSwag
The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
ldqk/Masuit.Tools
全龄段友好的C#万能工具库,码数吐司库,包含一些常用的操作类,大都是静态类,加密解密,反射操作,权重随机筛选算法,分布式短id,表达式树,linq扩展,文件压缩,多线程下载,硬件信息,字符串扩展方法,日期时间扩展操作,中国农历,大文件拷贝,图像裁剪,验证码,断点续传,集合扩展、Excel导出等常用封装。诸多功能集一身,代码量不到2MB!
aspnet/Mvc
[Archived] ASP.NET Core MVC is a model view controller framework for building dynamic web sites with clean separation of concerns, including the merged MVC, Web API, and Web Pages w/ Razor. Project moved to https://github.com/aspnet/AspNetCore
kurrent-io/KurrentDB
EventStoreDB, the event-native database. Designed for Event Sourcing, Event-Driven, and Microservices architectures
ChilliCream/graphql-platform
Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Nitro the awesome Monaco based GraphQL IDE.
domaindrivendev/Swashbuckle.AspNetCore
Swagger tools for documenting API's built on ASP.NET Core
FastEndpoints/FastEndpoints
A light-weight REST API development framework for ASP.NET 8 and newer.
openiddict/openiddict-core
Flexible and versatile OAuth 2.0/OpenID Connect stack for .NET
dotnetcore/Util
Util是一个.Net平台下的应用框架,旨在提升中小团队的开发能力,由工具类、分层架构基类、Ui组件,配套代码生成模板,权限等组成。
opserver/Opserver
Stack Exchange's Monitoring System
dotnet/aspire
Tools, templates, and packages to accelerate building observable, production-ready apps
grpc/grpc-dotnet
gRPC for .NET
Xabaril/AspNetCore.Diagnostics.HealthChecks
Enterprise HealthChecks for ASP.NET Core Diagnostics Package
Ombi-app/Ombi
Want a Movie or TV Show on Plex/Emby/Jellyfin? Use Ombi!
Version Downloads Last updated
10.0.0-preview.4.25255.103 0 5/12/2025
3.0.0-preview-19075-0444 2 1/28/2019
3.0.0-preview-18579-0056 2 11/30/2018
3.0.0-preview-18579-0053 3 11/30/2018