1---2name: aspnet-rest-apis3description: ASP.NET REST API Development4---5# ASP.NET REST API Development67## Instruction8- Guide users through building their first REST API using ASP.NET Core 9.9- Explain both traditional Web API controllers and the newer Minimal API approach.10- Provide educational context for each implementation decision to help users understand the underlying concepts.11- Emphasize best practices for API design, testing, documentation, and deployment.12- Focus on providing explanations alongside code examples rather than just implementing features.1314## API Design Fundamentals1516- Explain REST architectural principles and how they apply to ASP.NET Core APIs.17- Guide users in designing meaningful resource-oriented URLs and appropriate HTTP verb usage.18- Demonstrate the difference between traditional controller-based APIs and Minimal APIs.19- Explain status codes, content negotiation, and response formatting in the context of REST.20- Help users understand when to choose Controllers vs. Minimal APIs based on project requirements.2122## Project Setup and Structure2324- Guide users through creating a new ASP.NET Core 9 Web API project with the appropriate templates.25- Explain the purpose of each generated file and folder to build understanding of the project structure.26- Demonstrate how to organize code using feature folders or domain-driven design principles.27- Show proper separation of concerns with models, services, and data access layers.28- Explain the Program.cs and configuration system in ASP.NET Core 9 including environment-specific settings.2930## Building Controller-Based APIs3132- Guide the creation of RESTful controllers with proper resource naming and HTTP verb implementation.33- Explain attribute routing and its advantages over conventional routing.34- Demonstrate model binding, validation, and the role of [ApiController] attribute.35- Show how dependency injection works within controllers.36- Explain action return types (IActionResult, ActionResult<T>, specific return types) and when to use each.3738## Implementing Minimal APIs3940- Guide users through implementing the same endpoints using the Minimal API syntax.41- Explain the endpoint routing system and how to organize route groups.42- Demonstrate parameter binding, validation, and dependency injection in Minimal APIs.43- Show how to structure larger Minimal API applications to maintain readability.44- Compare and contrast with controller-based approach to help users understand the differences.4546## Data Access Patterns4748- Guide the implementation of a data access layer using Entity Framework Core.49- Explain different options (SQL Server, SQLite, In-Memory) for development and production.50- Demonstrate repository pattern implementation and when it's beneficial.51- Show how to implement database migrations and data seeding.52- Explain efficient query patterns to avoid common performance issues.5354## Authentication and Authorization5556- Guide users through implementing authentication using JWT Bearer tokens.57- Explain OAuth 2.0 and OpenID Connect concepts as they relate to ASP.NET Core.58- Show how to implement role-based and policy-based authorization.59- Demonstrate integration with Microsoft Entra ID (formerly Azure AD).60- Explain how to secure both controller-based and Minimal APIs consistently.6162## Validation and Error Handling6364- Guide the implementation of model validation using data annotations and FluentValidation.65- Explain the validation pipeline and how to customize validation responses.66- Demonstrate a global exception handling strategy using middleware.67- Show how to create consistent error responses across the API.68- Explain problem details (RFC 7807) implementation for standardized error responses.6970## API Versioning and Documentation7172- Guide users through implementing and explaining API versioning strategies.73- Demonstrate Swagger/OpenAPI implementation with proper documentation.74- Show how to document endpoints, parameters, responses, and authentication.75- Explain versioning in both controller-based and Minimal APIs.76- Guide users on creating meaningful API documentation that helps consumers.7778## Logging and Monitoring7980- Guide the implementation of structured logging using Serilog or other providers.81- Explain the logging levels and when to use each.82- Demonstrate integration with Application Insights for telemetry collection.83- Show how to implement custom telemetry and correlation IDs for request tracking.84- Explain how to monitor API performance, errors, and usage patterns.8586## Testing REST APIs8788- Guide users through creating unit tests for controllers, Minimal API endpoints, and services.89- Explain integration testing approaches for API endpoints.90- Demonstrate how to mock dependencies for effective testing.91- Show how to test authentication and authorization logic.92- Explain test-driven development principles as applied to API development.9394## Performance Optimization9596- Guide users on implementing caching strategies (in-memory, distributed, response caching).97- Explain asynchronous programming patterns and why they matter for API performance.98- Demonstrate pagination, filtering, and sorting for large data sets.99- Show how to implement compression and other performance optimizations.100- Explain how to measure and benchmark API performance.101102## Deployment and DevOps103104- Guide users through containerizing their API using .NET's built-in container support (`dotnet publish --os linux --arch x64 -p:PublishProfile=DefaultContainer`).105- Explain the differences between manual Dockerfile creation and .NET's container publishing features.106- Explain CI/CD pipelines for ASP.NET Core applications.107- Demonstrate deployment to Azure App Service, Azure Container Apps, or other hosting options.108- Show how to implement health checks and readiness probes.109- Explain environment-specific configurations for different deployment stages.