
Application Lifecycle
Startup, Program.cs, Host builder, WebApplicationBuilder, app shutdown, hosted services
1What is the main role of the Program.cs file in an ASP.NET Core application?
What is the main role of the Program.cs file in an ASP.NET Core application?
Answer
The Program.cs file centralizes the application startup code, including configuration of required services via Dependency Injection and definition of the request processing pipeline as middleware components. This approach consolidates all configuration in a single file, making it easier to manage and understand the app setup.
2Which method to use to create a WebApplicationBuilder with default settings?
Which method to use to create a WebApplicationBuilder with default settings?
Answer
WebApplication.CreateBuilder() is the standard method to initialize a WebApplicationBuilder with default configurations. This method automatically configures logging, configuration (appsettings.json, environment variables), Kestrel server, and other essential settings to start a modern ASP.NET Core application.
3Where to configure services required by the application before building the WebApplication?
Where to configure services required by the application before building the WebApplication?
Answer
The builder.Services property of WebApplicationBuilder provides access to the Dependency Injection container where all services are registered before building the application. This is the proper place to add services like AddControllers(), AddDbContext(), or any custom service with appropriate lifetimes (singleton, scoped, transient).
Which method to call on WebApplicationBuilder to build the application?
In an ASP.NET Core application, which middleware should be registered first for security?
+17 interview questions
Other .NET interview topics
C# Basics
LINQ & Delegates
C# Language Essentials
ASP.NET Core Fundamentals
ASP.NET Core Request Lifecycle
Configuration & Settings
Dependency Injection
Entity Framework Core
Minimal APIs
Web API Development
Async in ASP.NET Core
Authentication & Authorization
HttpClient & Networking
JSON Serialization
Entity Framework Core Advanced
C# Advanced Features
Clean Architecture
Logging, Monitoring & Observability
Unit Testing & xUnit
Integration Testing
Docker & Containerization
NuGet Package Management
Memory Management & GC
Reactive Programming
Async/await & Patterns
.NET Design Patterns
Performance Optimization
Security & Best Practices
SignalR & Real-time
Microservices Architecture
Master .NET for your next interview
Access all questions, flashcards, technical tests, code review exercises and interview simulators.
Start for free