.NET

Minimal APIs

Route handlers, parameter binding, filters, OpenAPI, route groups, performance

18 면접 질문·
Mid-Level
1

What is a Minimal API in ASP.NET Core?

답변

Minimal APIs are a simplified approach to creating HTTP APIs in ASP.NET Core, introduced with .NET 6. They allow defining endpoints directly in Program.cs without requiring controllers or complex configuration. This approach reduces boilerplate code and improves performance for simple to moderately complex APIs, while offering a more modern and functional development experience.

2

Which method allows defining a GET endpoint in Minimal APIs?

답변

MapGet is the dedicated method for registering an HTTP GET endpoint in Minimal APIs. It takes as parameters the route pattern and a delegate that defines the processing logic. This method is part of the Map* method family which also includes MapPost, MapPut, MapDelete, and MapPatch for other HTTP verbs.

3

How to bind a route parameter in a Minimal API endpoint?

답변

Route parameter binding in Minimal APIs is done automatically by naming convention. Simply define a parameter in the route pattern between curly braces, then declare a parameter with the same name in the handler signature. ASP.NET Core automatically performs the binding and type conversion. For example, for a pattern /users/{id}, an int id parameter will be automatically bound and converted.

4

What is the difference between Results and TypedResults in Minimal APIs?

5

How to inject a service into a Minimal API handler?

+15 면접 질문

다음 면접을 위해 .NET을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기