ASP.NET Core Interview Question #6
What is WebApplication in ASP.NET Core?
ASP.NET Core Fundamentals Junior Beginner
Quick Interview Answer
WebApplication represents the configured ASP.NET Core application after WebApplicationBuilder.Build() is called. It implements the application host and provides methods for configuring middleware and mapping endpoints.
Detailed Explanation
WebApplication represents the configured ASP.NET Core application after WebApplicationBuilder.Build() is called. It implements the application host and provides methods for configuring middleware and mapping endpoints.
Typical operations on WebApplication include UseExceptionHandler, UseHttpsRedirection, UseStaticFiles, UseRouting, UseAuthentication, UseAuthorization, MapControllers, MapRazorPages, and Run.
Code Example
var app = builder.Build();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.Run();