ASP.NET Core Web API Interview Question #80
What is a catch-all route parameter?
Routing, Versioning, OpenAPI/Swagger & API Documentation Mid-Level Intermediate
Quick Interview Answer
A catch-all route parameter captures the remaining path segments into one route value. It is useful for endpoints that intentionally accept path-like data.
Detailed Explanation
A catch-all route parameter captures the remaining path segments into one route value. It is useful for endpoints that intentionally accept path-like data.
Catch-all routes are broad and can make routing ambiguous, so they should be used only when the API contract genuinely requires them.
Code Example
[HttpGet("files/{**path}")]
public IActionResult GetFile(string path)
{
return Ok(new { path });
}