ASP.NET Core Web API Interview Question #1

What is ASP.NET Core Web API?

Web API & REST Fundamentals, Controllers, HTTP Methods & Status Codes Junior Beginner

Quick Interview Answer

ASP.NET Core Web API is a framework for building HTTP services on .NET. It is commonly used to expose application data and operations to web applications, mobile apps, desktop clients, other services, and third-party integrations.

Detailed Explanation

ASP.NET Core Web API is a framework for building HTTP services on .NET. It is commonly used to expose application data and operations to web applications, mobile apps, desktop clients, other services, and third-party integrations.

A Web API normally receives an HTTP request, uses routing and model binding to select an endpoint and construct its input, executes application logic, and returns an HTTP response such as JSON together with an appropriate status code.

Code Example

[ApiController]
[Route("api/[controller]")]
public class ProductsController : ControllerBase
{
    [HttpGet]
    public IActionResult Get()
    {
        return Ok(new[] { "Laptop", "Phone" });
    }
}