ASP.NET Core Interview Question #39

What is WebApplication?

Application Structure & Configuration Junior Beginner

Quick Interview Answer

WebApplication represents the configured ASP.NET Core application and combines hosting, middleware pipeline configuration, endpoint routing, and application lifetime functionality.

Detailed Explanation

WebApplication represents the configured ASP.NET Core application and combines hosting, middleware pipeline configuration, endpoint routing, and application lifetime functionality.

After builder.Build(), the WebApplication instance is used with methods such as UseRouting(), UseAuthentication(), UseAuthorization(), MapControllers(), MapControllerRoute(), and MapGet().

Finally, app.Run() starts the host and begins processing requests. Middleware ordering on the WebApplication is significant because requests flow through the pipeline in the configured order.

Code Example

var app = builder.Build();

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();

app.MapControllers();

app.Run();