Skip to main content

Stage 1 - ASP.NET Core Fundamentals and Request Pipeline

Q1. What is ASP.NET Core?

Quick interview answer: ASP.NET Core is a modern, cross-platform web framework from Microsoft for building Web APIs, MVC applications, Razor Pages, real-time apps, and backend services using .NET and C#.

Study in detail: What is ASP.NET Core? - This article expands the topic with complete explanation, examples, and practice tasks.

Q2. Why is ASP.NET Core important for backend developers?

Quick interview answer: ASP.NET Core is important because many companies use it to build APIs, business applications, authentication systems, admin portals, and cloud services. It has built-in dependency injection, configuration, logging, middleware, routing, and security support.

Study in detail: What is ASP.NET Core? - This article explains where ASP.NET Core fits in backend development.

Q3. What tools are needed to create an ASP.NET Core project?

Quick interview answer: We need the .NET SDK, a code editor such as Visual Studio or VS Code, and a terminal. The SDK gives commands like dotnet new, dotnet build, and dotnet run.

Study in detail: Setup: Create Your First Project - This article explains project creation and first run.

Q4. What is Program.cs in ASP.NET Core?

Quick interview answer: Program.cs is the main startup file. It creates the application builder, registers services, builds the app, configures middleware, maps endpoints, and starts the application.

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();

var app = builder.Build();
app.MapControllers();
app.Run();

Study in detail: Program.cs and the Host Builder - This article explains each part of Program.cs.

Q5. What is the request pipeline?

Quick interview answer: The request pipeline is the ordered sequence of middleware components that handle every HTTP request and response. Each middleware can process the request, call the next middleware, or stop the request.

Request -> Middleware 1 -> Middleware 2 -> Endpoint -> Response

Study in detail: How ASP.NET Core Handles Requests - This article explains the request and response flow.

Q6. Why does middleware order matter?

Quick interview answer: Middleware runs in the order it is registered. If the order is wrong, features may not work correctly. For example, authentication must run before authorization, and exception handling should be registered early.

Study in detail: How ASP.NET Core Handles Requests - This article explains pipeline order.

Q7. What is middleware?

Quick interview answer: Middleware is a component in the HTTP pipeline. It can inspect or modify requests and responses. Examples include static files, routing, CORS, authentication, authorization, and exception handling.

app.Use(async (context, next) =>
{
await next();
});

Study in detail: Middleware - Building Custom Request Processors - This article explains built-in and custom middleware.

Q8. What is the difference between app.Use, app.Run, and app.Map?

Quick interview answer: app.Use adds middleware that can call the next middleware. app.Run adds terminal middleware that ends the pipeline. app.Map branches or maps requests to specific paths or endpoints.

Use = can continue
Run = terminal
Map = route/branch

Study in detail: Middleware - Building Custom Request Processors - This article shows middleware patterns.

Q9. What is routing in ASP.NET Core?

Quick interview answer: Routing maps incoming URLs and HTTP methods to endpoint code or controller actions. It decides which handler should run for a request.

app.MapGet("/students/{id}", (int id) => $"Student {id}");

Study in detail: Routing - Mapping URLs to Code - This article explains route parameters and constraints.

Q10. What are route parameters?

Quick interview answer: Route parameters capture values from the URL and pass them to code.

app.MapGet("/students/{id}", (int id) => Results.Ok(id));

For /students/101, id becomes 101.

Study in detail: Routing - Mapping URLs to Code - This article covers route parameters, query strings, and route design.

nexcoding.in