Routing & Controllers Flashcards
6 cards from real ASP.NET Core practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Routing & Controllers flashcards as text
What is the role of UseEndpoints() in ASP.NET Core routing?
Answer: It executes the endpoints matched by UseRouting()
UseEndpoints() is where endpoint execution happens; UseRouting() does the matching and UseEndpoints() runs the matched handler.
What does [Area("Admin")] attribute do on a controller?
Answer: Associates the controller with the Admin routing area for URL organization
[Area] groups controllers into named areas, allowing separate folder structures and route namespaces like /admin/controller/action.
Which method adds conventional MVC routing with a default template in ASP.NET Core?
Answer: app.MapControllerRoute()
app.MapControllerRoute() registers a named conventional route with a template like {controller=Home}/{action=Index}/{id?}.
How does [FromQuery] bind action parameters in ASP.NET Core?
Answer: It reads the value from the URL query string
[FromQuery] explicitly binds the parameter from the query string portion of the URL (?key=value).
What does calling Problem() helper method return in an ASP.NET Core API controller?
Answer: An ObjectResult with ProblemDetails payload and appropriate status code
Problem() creates an RFC 7807 ProblemDetails response body with a status code, conforming to the standard error format for APIs.
Which attribute restricts an action to accept only HTTP POST requests?
Answer: [HttpPost]
[HttpPost] constrains the route to match only POST requests, returning 405 Method Not Allowed for other verbs.