Microsoft.AspNetCore.TestHost
10.0.3
Prefix Reserved
See the version list below for details.
dotnet add package Microsoft.AspNetCore.TestHost --version 10.0.3
NuGet\Install-Package Microsoft.AspNetCore.TestHost -Version 10.0.3
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="10.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="10.0.3" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" />
paket add Microsoft.AspNetCore.TestHost --version 10.0.3
#r "nuget: Microsoft.AspNetCore.TestHost, 10.0.3"
#:package Microsoft.AspNetCore.TestHost@10.0.3
#addin nuget:?package=Microsoft.AspNetCore.TestHost&version=10.0.3
#tool nuget:?package=Microsoft.AspNetCore.TestHost&version=10.0.3
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: AnIServerimplementation for executing testsTestServerOptions: Provides options for configuring aTestServer
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 | Versions 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. |
-
net10.0
- No dependencies.
NuGet packages (184)
Showing the top 5 NuGet packages that depend on Microsoft.AspNetCore.TestHost:
| Package | 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/87bc0b04e21d786669142109a5128c95618b75ed |
|
|
Rystem.Test.XUnit
Rystem is a open-source framework to improve the System namespace in .Net |
|
|
Reo.Core.IntegrationTesting
Package Description |
|
|
MyTested.AspNetCore.Mvc.Abstractions
My Tested ASP.NET Core MVC common abstractions and interfaces. |
|
|
Acheve.TestHost
Achve.TestHost is a nuget package to improve TestServer experiences. For more information see http://github.com/Xabaril/Acheve.TestHost |
GitHub repositories (225)
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/eShop
A reference .NET application implementing an eCommerce site
|
|
|
dotnet/yarp
A toolkit for developing high-performance HTTP reverse proxy applications.
|
|
|
ThreeMammals/Ocelot
.NET API Gateway
|
|
|
RicoSuter/NSwag
The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
|
|
|
ldqk/Masuit.Tools
全龄段友好的C#万能工具库,码数吐司库,包含一些常用的操作类,大都是静态类,加密解密,反射操作,权重随机筛选算法,分布式短id,表达式树,linq扩展,文件压缩,多线程下载,硬件信息,字符串扩展方法,日期时间扩展操作,中国农历,大文件拷贝,图像裁剪,验证码,断点续传,集合扩展、Excel导出等常用封装。诸多功能集一身,代码量不到2MB!
|
|
|
FastEndpoints/FastEndpoints
A light-weight REST API development framework for ASP.NET 8 and newer.
|
|
|
kurrent-io/KurrentDB
KurrentDB is a database that's engineered for modern software applications and event-driven architectures. Its event-native design simplifies data modeling and preserves data integrity while the integrated streaming engine solves distributed messaging challenges and ensures data consistency.
|
|
|
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.
|
|
|
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
|
|
|
domaindrivendev/Swashbuckle.AspNetCore
Swagger tools for documenting API's built on ASP.NET Core
|
|
|
dotnet/aspire
Aspire is the tool for code-first, extensible, observable dev and deploy.
|
|
|
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
|
|
|
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 |
|---|---|---|
| 11.0.0-preview.1.26104.118 | 526 | 2/10/2026 |
| 10.0.3 | 125,287 | 2/10/2026 |
| 10.0.2 | 1,464,167 | 1/13/2026 |
| 10.0.1 | 1,519,191 | 12/9/2025 |
| 10.0.0 | 2,163,257 | 11/11/2025 |
| 10.0.0-rc.2.25502.107 | 100,545 | 10/14/2025 |
| 10.0.0-rc.1.25451.107 | 77,315 | 9/9/2025 |
| 10.0.0-preview.7.25380.108 | 35,936 | 8/12/2025 |
| 9.0.13 | 17,728 | 2/10/2026 |
| 9.0.12 | 227,589 | 1/13/2026 |
| 9.0.11 | 1,341,510 | 11/11/2025 |
| 9.0.10 | 2,423,008 | 10/14/2025 |
| 9.0.9 | 2,575,326 | 9/9/2025 |
| 8.0.24 | 31,924 | 2/10/2026 |
| 8.0.23 | 373,308 | 1/13/2026 |
| 8.0.22 | 1,932,662 | 11/11/2025 |
| 8.0.21 | 1,723,016 | 10/14/2025 |
| 8.0.20 | 1,750,310 | 9/9/2025 |
| 2.3.9 | 10,832 | 1/7/2026 |
| 2.3.8 | 16,580 | 1/7/2026 |