$npx -y skills add managedcode/dotnet-skills --skill aspnet-coreBuild, debug, modernize, or review ASP.NET Core applications with correct hosting, middleware, security, configuration, logging, and deployment patterns on current .NET. USE FOR: working on ASP.NET Core apps, services, or middleware; changing auth, routing, configuration, hosting
| 1 | # ASP.NET Core |
| 2 | |
| 3 | ## Trigger On |
| 4 | |
| 5 | - working on ASP.NET Core apps, services, or middleware |
| 6 | - changing auth, routing, configuration, hosting, or deployment behavior |
| 7 | - deciding between ASP.NET Core sub-stacks such as Blazor, Minimal APIs, or controller APIs |
| 8 | - debugging request pipeline issues |
| 9 | - modernizing legacy ASP.NET to ASP.NET Core |
| 10 | |
| 11 | ## Documentation |
| 12 | |
| 13 | - [ASP.NET Core Overview](https://learn.microsoft.com/en-us/aspnet/core/?view=aspnetcore-10.0) |
| 14 | - [ASP.NET Core Middleware](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-10.0) |
| 15 | - [ASP.NET Core Best Practices](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/best-practices?view=aspnetcore-10.0) |
| 16 | - [Configuration in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-10.0) |
| 17 | - [Authentication and Authorization](https://learn.microsoft.com/en-us/aspnet/core/security/?view=aspnetcore-10.0) |
| 18 | |
| 19 | ### References |
| 20 | |
| 21 | - [patterns.md](references/patterns.md) - Detailed middleware patterns, security patterns, configuration patterns, DI patterns, error handling patterns, and logging patterns |
| 22 | - [anti-patterns.md](references/anti-patterns.md) - Common ASP.NET Core mistakes including HttpClient misuse, async anti-patterns, configuration errors, DI issues, middleware ordering problems, and security vulnerabilities |
| 23 | |
| 24 | ## Workflow |
| 25 | |
| 26 | 1. **Detect the real hosting shape first:** |
| 27 | - top-level `Program.cs` structure |
| 28 | - middleware order and registration |
| 29 | - auth model (Identity, JWT, OAuth, cookies) |
| 30 | - endpoint registrations and routing |
| 31 | |
| 32 | 2. **Follow the correct middleware order:** |
| 33 | ``` |
| 34 | ExceptionHandler → HttpsRedirection → Static Files → Routing |
| 35 | → CORS → Authentication → Authorization → Rate Limiting |
| 36 | → Response Caching → Custom Middleware → Endpoints |
| 37 | ``` |
| 38 | |
| 39 | 3. **Use built-in patterns correctly:** |
| 40 | - Prefer `IOptions<T>` / `IOptionsSnapshot<T>` for configuration |
| 41 | - Use `ILogger<T>` for structured logging |
| 42 | - Use `IHttpClientFactory` for HTTP clients (never `new HttpClient()`) |
| 43 | - Use `IHostedService` / `BackgroundService` for background work |
| 44 | |
| 45 | 4. **Route specialized work to specific skills:** |
| 46 | - UI and components → `blazor` |
| 47 | - Real-time → `signalr` |
| 48 | - RPC → `grpc` |
| 49 | - New HTTP APIs → `minimal-apis` (prefer unless controllers needed) |
| 50 | - Controller APIs → `web-api` |
| 51 | |
| 52 | 5. **Validate with build, tests, and targeted endpoint checks.** |
| 53 | |
| 54 | ## Current Upstream Notes |
| 55 | |
| 56 | - ASP.NET Core `v10.0.10` is servicing rather than a new programming model. It fixes data-protection cold-start thread-pool starvation, rejects ASCII control characters in cookie-auth return URLs, skips indexers in validation source generation, and repairs nullable/OpenAPI metadata cases. Keep existing middleware and endpoint architecture, then rerun focused auth, startup, validation, and OpenAPI tests. |
| 57 | - The July 2026 Microsoft Learn overview for `aspnetcore-10.0` remains the routing entry point for choosing between Blazor, Minimal APIs, controller APIs, SignalR, and gRPC; the refresh does not justify changing an existing app model by itself. |
| 58 | |
| 59 | ## Middleware Patterns |
| 60 | |
| 61 | ### Correct Order Matters |
| 62 | ```csharp |
| 63 | var app = builder.Build(); |
| 64 | |
| 65 | app.UseExceptionHandler("/error"); // 1. Catch all exceptions |
| 66 | app.UseHsts(); // 2. Security headers |
| 67 | app.UseHttpsRedirection(); // 3. HTTPS redirect |
| 68 | app.UseStaticFiles(); // 4. Serve static files |
| 69 | app.UseRouting(); // 5. Route matching |
| 70 | app.UseCors(); // 6. CORS policy |
| 71 | app.UseAuthentication(); // 7. Who are you? |
| 72 | app.UseAuthorization(); // 8. Can you access? |
| 73 | app.UseRateLimiter(); // 9. Rate limiting |
| 74 | app.UseResponseCaching(); // 10. Response cache |
| 75 | app.MapControllers(); // 11. Endpoints |
| 76 | ``` |
| 77 | |
| 78 | ### Custom Middleware Pattern |
| 79 | ```csharp |
| 80 | public class RequestTimingMiddleware |
| 81 | { |
| 82 | private readonly RequestDelegate _next; |
| 83 | private readonly ILogger<RequestTimingMiddleware> _logger; |
| 84 | |
| 85 | public RequestTimingMiddleware(RequestDelegate next, ILogger<RequestTimingMiddleware> logger) |
| 86 | { |
| 87 | _next = next; |
| 88 | _logger = logger; |
| 89 | } |
| 90 | |
| 91 | public async Task InvokeAsync(HttpContext context) |
| 92 | { |
| 93 | var sw = Stopwatch.StartNew(); |
| 94 | a |