Program.cs
The source file where a .NET application starts, usually holding top-level statements that build and run the host.
In more detail
In a web API it creates the WebApplication builder, registers services, configures the middleware pipeline and maps endpoints. Integration tests refer to its generated Program class through WebApplicationFactory<Program>.
Related terms
- top-level statements — C# code written directly at the top of Program.cs, without a class or Main method, from which the compiler generates the program's entry point.
- WebApplication — The ASP.NET Core host object that owns configuration, services and the middleware pipeline, created by WebApplication.CreateBuilder(args) and started with app.Run().
- WebApplicationFactory — An ASP.NET Core testing class that starts your real application in memory and gives tests an HttpClient connected to it.
Taught in
- What is .NET? Runtime vs SDK, and LTS vs STS — Modern .NET Core, C# & Enterprise Microservices
- Records, Pattern Matching, and Modern C# — Modern .NET Core, C# & Enterprise Microservices
- Integration Testing with WebApplicationFactory — Modern .NET Core, C# & Enterprise Microservices