LEARN BUILD GROW TOGETHER
DEVELOPER LEARNING HUB
Learn. Build. Grow Together.

Practical tutorials, real-world examples and interview preparation.

.NETC#SQL SERVERANGULAR
Home /.NET /240 ASP.NET Core Web API Interview Questions – Basic to Advanced

240 ASP.NET Core Web API Interview Questions – Basic to Advanced

 ASP.NET Core Web API is a framework for building RESTful services and HTTP-based APIs using .NET. It supports modern application development through features such as dependency injection, middleware, routing, model binding, authentication, authorization, and integration with databases and external services.

Whether you are preparing for a junior, intermediate, or senior .NET developer interview, understanding these concepts is important for designing, developing, securing, and maintaining scalable Web APIs.

This question bank covers 220 ASP.NET Core Web API interview questions, organized from basic to advanced levels, including practical and scenario-based questions.

Section 1: ASP.NET Core Web API Fundamentals

  1. What is ASP.NET Core Web API?

  2. What is the difference between ASP.NET Web API 2 and ASP.NET Core Web API?

  3. What are the main features of ASP.NET Core Web API?

  4. What is the difference between ASP.NET Core MVC and ASP.NET Core Web API?

  5. What is REST architecture?

  6. What are the principles of REST?

  7. What is a RESTful API?

  8. What is the difference between REST and SOAP?

  9. What is the difference between an API and a Web API?

  10. What is the role of HTTP in Web API?

  11. What is the difference between stateless and stateful communication?

  12. What is the purpose of the Program.cs file in an ASP.NET Core Web API application?

  13. What is the role of WebApplication and WebApplicationBuilder?

  14. What is the purpose of appsettings.json?

  15. What is the difference between Development, Staging, and Production environments?

  16. What is the purpose of launchSettings.json?

  17. What is Kestrel?

  18. What is the difference between Kestrel and IIS?

  19. What is the purpose of the .csproj file?

  20. What is the difference between a controller-based API and a Minimal API?

Section 2: Controllers and Action Methods

  1. What is a controller in ASP.NET Core Web API?

  2. What is the purpose of the ControllerBase class?

  3. What is the difference between Controller and ControllerBase?

  4. Why do Web API controllers commonly inherit from ControllerBase?

  5. What is the purpose of the [ApiController] attribute?

  6. What is the difference between [ApiController] and [Controller]?

  7. What is the purpose of the [Route] attribute?

  8. What is the purpose of the [HttpGet] attribute?

  9. What is the purpose of the [HttpPost] attribute?

  10. What is the purpose of the [HttpPut] attribute?

  11. What is the purpose of the [HttpPatch] attribute?

  12. What is the purpose of the [HttpDelete] attribute?

  13. What is the difference between an action method and a controller method?

  14. What is IActionResult?

  15. What is the difference between IActionResult and ActionResult<T>?

  16. What is the purpose of ActionResult<T>?

  17. What is the difference between returning Ok(), Created(), and NoContent()?

  18. What is the purpose of CreatedAtAction()?

  19. What is the difference between returning a POCO object and IActionResult?

  20. Can an action method return an asynchronous response?

  21. What is the purpose of async and await in controller actions?

  22. What is the difference between ActionResult and ActionResult<T>?

  23. How do you return a custom HTTP status code from a controller?

  24. How do you handle multiple HTTP methods in a controller?

  25. What is the purpose of ProducesResponseTypeAttribute?

Section 3: HTTP Methods and Status Codes

  1. What are the commonly used HTTP methods in Web API?

  2. What is the difference between GET and POST?

  3. What is the difference between PUT and PATCH?

  4. What is the difference between POST and PUT?

  5. What is the difference between DELETE and soft delete?

  6. What is idempotency in HTTP?

  7. Which HTTP methods are considered idempotent?

  8. Is POST an idempotent HTTP method?

  9. Is PUT an idempotent HTTP method?

  10. What is the difference between safe and idempotent HTTP methods?

  11. What is HTTP status code 200?

  12. What is the difference between 200 OK and 201 Created?

  13. When should you return 204 No Content?

  14. What does 400 Bad Request indicate?

  15. What is the difference between 401 Unauthorized and 403 Forbidden?

  16. What does 404 Not Found indicate?

  17. What is the purpose of 405 Method Not Allowed?

  18. What is the difference between 409 Conflict and 400 Bad Request?

  19. When should you return 422 Unprocessable Content?

  20. What does 500 Internal Server Error indicate?

Section 4: Routing and Endpoint Management

  1. What is routing in ASP.NET Core Web API?

  2. What is the difference between conventional routing and attribute routing?

  3. What is attribute routing?

  4. How do you define a route at the controller level?

  5. How do you define a route at the action level?

  6. What are route parameters?

  7. What is the difference between route parameters and query string parameters?

  8. What are route constraints?

  9. How do you define an integer route constraint?

  10. What is the purpose of the {id} route constraint?

  11. What is the purpose of optional route parameters?

  12. What is the difference between [Route("api/[controller]")] and [Route("api/products")]?

  13. What is route token replacement?

  14. What is the purpose of the [FromRoute] attribute?

  15. What happens when two API endpoints have ambiguous routes?

  16. What is endpoint routing?

  17. What is the purpose of MapControllers()?

  18. What is the difference between UseRouting() and MapControllers()?

  19. How do you implement API versioning through URL routing?

  20. What is the purpose of route names in ASP.NET Core Web API?

Section 5: Model Binding and Validation

  1. What is model binding in ASP.NET Core Web API?

  2. How does model binding work?

  3. What are the different sources used for model binding?

  4. What is the purpose of the [FromBody] attribute?

  5. What is the purpose of the [FromQuery] attribute?

  6. What is the purpose of the [FromRoute] attribute?

  7. What is the purpose of the [FromForm] attribute?

  8. What is the purpose of the [FromHeader] attribute?

  9. What is the difference between [FromBody] and [FromForm]?

  10. Can an API action method have multiple parameters decorated with [FromBody]?

  11. What is model validation?

  12. What are Data Annotations?

  13. What is the purpose of the [Required] attribute?

  14. What is the purpose of the [StringLength] attribute?

  15. What is the purpose of the [Range] attribute?

  16. What is the purpose of the [RegularExpression] attribute?

  17. What is ModelState?

  18. How do you check whether ModelState is valid?

  19. How does the [ApiController] attribute handle invalid model state?

  20. How do you implement custom validation in ASP.NET Core Web API?

Section 6: Dependency Injection and Service Lifetimes

  1. What is dependency injection?

  2. Why is dependency injection important in ASP.NET Core Web API?

  3. How do you register a service in the dependency injection container?

  4. What is the difference between AddTransient(), AddScoped(), and AddSingleton()?

  5. What is a transient service?

  6. What is a scoped service?

  7. What is a singleton service?

  8. What is the lifetime of a DbContext registered using AddDbContext() by default?

  9. What happens when a scoped service is injected into a singleton service?

  10. What is constructor injection?

  11. What is the difference between constructor injection and method injection?

  12. What is the IServiceCollection interface?

  13. What is the IServiceProvider interface?

  14. What is the purpose of the extension method pattern for service registration?

  15. How do you register multiple implementations of the same interface?

  16. How can you resolve multiple implementations of an interface?

  17. What is the purpose of the Options pattern?

  18. What is the difference between IOptions, IOptionsSnapshot, and IOptionsMonitor?

  19. How do you register and consume configuration settings through dependency injection?

  20. Why should business logic be separated from controllers?

Section 7: Middleware and Request Pipeline

  1. What is middleware in ASP.NET Core?

  2. How does the ASP.NET Core request pipeline work?

  3. What is the difference between middleware and filters?

  4. What is the purpose of Use()?

  5. What is the purpose of Run()?

  6. What is the purpose of Map()?

  7. What is the difference between app.Use() and app.Run()?

  8. What is terminal middleware?

  9. What is the purpose of UseRouting()?

  10. What is the purpose of UseAuthentication()?

  11. What is the purpose of UseAuthorization()?

  12. Why does middleware execution order matter?

  13. Where should authentication and authorization middleware be placed in the request pipeline?

  14. What is custom middleware?

  15. How do you create custom middleware using RequestDelegate?

  16. What is the purpose of Invoke() or InvokeAsync() in middleware?

  17. How do you read request headers inside middleware?

  18. How do you handle exceptions globally using middleware?

  19. What is the difference between UseExceptionHandler() and DeveloperExceptionPage?

  20. How do you implement request logging using custom middleware?

Section 8: Filters and Exception Handling

  1. What are filters in ASP.NET Core Web API?

  2. What are the different types of filters?

  3. What is an authorization filter?

  4. What is a resource filter?

  5. What is an action filter?

  6. What is an exception filter?

  7. What is a result filter?

  8. What is the execution order of ASP.NET Core MVC filters?

  9. What is the difference between IAsyncActionFilter and IActionFilter?

  10. How do you create a custom action filter?

  11. What is the purpose of ActionFilterAttribute?

  12. What is the difference between exception middleware and exception filters?

  13. How do you implement centralized exception handling?

  14. What is ProblemDetails?

  15. What is the purpose of IExceptionHandler in modern ASP.NET Core applications?

Section 9: Authentication and Authorization

  1. What is authentication?

  2. What is authorization?

  3. What is the difference between authentication and authorization?

  4. What is JWT authentication?

  5. What are the main parts of a JWT token?

  6. What is the purpose of the JWT header, payload, and signature?

  7. How do you implement JWT authentication in ASP.NET Core Web API?

  8. What is the purpose of AddAuthentication()?

  9. What is the purpose of AddJwtBearer()?

  10. What is the purpose of the [Authorize] attribute?

  11. What is the purpose of the [AllowAnonymous] attribute?

  12. What is the difference between role-based and policy-based authorization?

  13. What is claims-based authorization?

  14. What is the difference between roles and claims?

  15. How do you implement role-based authorization?

  16. How do you implement policy-based authorization?

  17. What is the purpose of the [Authorize(Roles = "...")] attribute?

  18. What is token expiration?

  19. What is a refresh token?

  20. How do you protect an API from unauthorized access?

Section 10: Database Integration and Entity Framework Core

  1. How do you connect ASP.NET Core Web API to SQL Server?

  2. What is Entity Framework Core?

  3. What is the difference between Entity Framework Core and Dapper?

  4. What is DbContext?

  5. What is DbSet?

  6. What is the purpose of AddDbContext()?

  7. What is the difference between Code First and Database First approaches?

  8. What are EF Core migrations?

  9. What is the difference between Add-Migration and Update-Database?

  10. What is the difference between FirstOrDefault() and SingleOrDefault()?

  11. What is the difference between Find() and FirstOrDefault()?

  12. What is the difference between eager loading, lazy loading, and explicit loading?

  13. What is the purpose of Include() and ThenInclude()?

  14. What is AsNoTracking() and when should it be used?

  15. How do you implement transactions in Entity Framework Core?

  16. What is the purpose of SaveChangesAsync()?

  17. How do you prevent SQL injection when using Entity Framework Core?

  18. What is the repository pattern?

  19. What is the Unit of Work pattern?

  20. How do you manage database connection strings securely?

Section 11: API Security, Performance, and Advanced Concepts

  1. What is CORS?

  2. Why is CORS required in Web API applications?

  3. How do you configure CORS in ASP.NET Core?

  4. What is rate limiting?

  5. How do you implement rate limiting in ASP.NET Core Web API?

  6. What is the difference between fixed window, sliding window, and token bucket rate limiting?

  7. What is API versioning?

  8. Why is API versioning important?

  9. What are the different approaches to API versioning?

  10. What is response caching?

  11. What is output caching?

  12. What is the difference between response caching and output caching?

  13. What is pagination?

  14. How do you implement pagination in Web API?

  15. What is the difference between pagination and filtering?

  16. What is content negotiation?

  17. What is serialization and deserialization?

  18. What is the difference between System.Text.Json and Newtonsoft.Json?

  19. What is the purpose of IHttpClientFactory?

  20. How do you improve the performance and scalability of an ASP.NET Core Web API?

Section 12: Scenario-Based and Practical Questions

  1. Your API is receiving thousands of requests per minute. How would you prevent excessive requests from a single client?

  2. An API endpoint takes several seconds to return data. How would you identify and improve the performance bottleneck?

  3. Your API is returning HTTP 500 errors in production. How would you investigate and troubleshoot the issue?

  4. A user submits the same POST request multiple times due to a network timeout. How would you prevent duplicate records?

  5. Your API needs to communicate with an external third-party API. How would you implement HTTP client calls with timeout and retry handling?

  6. How would you secure an API that is accessed by an Angular application?

  7. Your application has multiple user roles, and each role can access different API endpoints. How would you implement authorization?

  8. How would you handle large file uploads in ASP.NET Core Web API?

  9. Your API needs to return a large amount of data. How would you implement pagination and filtering?

  10. How would you implement centralized exception handling across all API controllers?

  11. Your API needs to support multiple versions without breaking existing clients. How would you design API versioning?

  12. How would you prevent SQL injection attacks in your Web API?

  13. Your API is receiving requests from an Angular application hosted on a different domain. How would you configure CORS?

  14. How would you implement JWT authentication with refresh tokens?

  15. A database operation fails after some records have already been inserted. How would you ensure data consistency?

  16. How would you handle concurrent requests that update the same database record?

  17. Your API needs to process a time-consuming operation without making the client wait. How would you design this functionality?

  18. How would you implement logging and correlation IDs to trace a request across multiple services?

  19. How would you deploy an ASP.NET Core Web API application to IIS or Azure?

  20. How would you design a Web API that can handle high traffic and scale horizontally?

Important Note

ASP.NET Core Web API is different from classic ASP.NET Web API 2. Modern ASP.NET Core Web API applications use the ASP.NET Core hosting model, built-in dependency injection, middleware, endpoint routing, and modern authentication and authorization mechanisms.

This question bank focuses on ASP.NET Core Web API concepts and modern .NET development. Topics such as Entity Framework Core, SQL Server, JWT authentication, API security, performance optimization, and integration testing are important supporting areas for real-world API development.

The MVC and Web API interview question banks are covered separately so that you can prepare for both application development approaches independently.


Skills Tutorials – Learn • Build • Grow Together

Continue learning with our tutorials and interview preparation series.