dotnet-aspnet-core

Build, debug, and modernize ASP.NET Core applications with correct middleware, security, and configuration patterns.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/zhenpengLai/myuseskill --skill dotnet-aspnet-core-zhenpenglai
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dotnet-aspnet-core
Source: https://github.com/zhenpengLai/myuseskill/tree/main/dotnet-aspnet-core
Command: npx skills add https://github.com/zhenpengLai/myuseskill --skill dotnet-aspnet-core-zhenpenglai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? ASP.NET Core applications frequently suffer from misordered middleware, HttpClient socket exhaustion, sync-over-async deadlocks, leaked secrets, and misconfigured authentication. This Skill provides the correct hosting, middleware, security, configuration, logging, and deployment patterns so these mistakes are caught and fixed before they reach production. ## Core Features & Use Cases - Middleware Pipeline Guidance: Enforces the canonical middleware order (ExceptionHandler, HTTPS redirection, Routing, CORS, Authentication, Authorization, Rate Limiting, Endpoints) and provides custom middleware patterns. - Security & Configuration Patterns: Covers JWT and cookie authentication, policy-based authorization, CORS, rate limiting, strongly-typed options with validation, and secret management via User Secrets and Key Vault. - Anti-Pattern Catalog: A detailed reference of common mistakes including captive dependencies, N+1 queries, fat controllers, SQL injection, and async void, each with corrected code. - Use Case: When modernizing a legacy ASP.NET application to ASP.NET Core, use this Skill to restructure Program.cs, fix middleware ordering, replace new HttpClient() with IHttpClientFactory, and move secrets out of appsettings.json. ## Quick Start Review my ASP.NET Core application's middleware pipeline and Program.cs configuration, and fix any ordering, security, or dependency injection issues you find.

Frequently Asked Questions about dotnet-aspnet-core

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the correct middleware order in ASP.NET Core?▼

The canonical order is ExceptionHandler, HSTS, HttpsRedirection, StaticFiles, Routing, CORS, Authentication, Authorization, Rate Limiting, Response Caching, custom middleware, then endpoint mapping. Placing authentication before routing or exception handling last causes authorization failures and uncaught exceptions.

Why should I use IHttpClientFactory instead of new HttpClient?▼

Creating HttpClient directly causes socket exhaustion because disposed instances leave sockets in TIME_WAIT state, while static instances cache DNS indefinitely. IHttpClientFactory pools and rotates handlers, solving both problems, and supports typed clients with Polly retry and circuit breaker policies.

How do I store secrets securely in ASP.NET Core?▼

Never commit secrets to appsettings.json since they persist in git history. Use User Secrets in development via dotnet user-secrets, and environment variables or Azure Key Vault in production, keeping only non-sensitive placeholders in configuration files.

When should I use Minimal APIs versus controller-based Web APIs?▼

Prefer Minimal APIs for new HTTP APIs unless controllers are specifically needed. This Skill routes new HTTP API work to dotnet-minimal-apis by default and controller-based APIs to dotnet-web-api, while UI work goes to dotnet-blazor and real-time work to dotnet-signalr.

Why does my ASP.NET Core app deadlock with async code?▼

Deadlocks and thread pool starvation come from sync-over-async patterns like calling .Result or .GetAwaiter().GetResult() on tasks. Make the entire call chain async with await, and never use async void in middleware since exceptions will crash the process.

Can I register DbContext as a singleton in dependency injection?▼

No, DbContext is not thread-safe and tracks entities, so singleton registration causes concurrency issues and memory leaks. Use AddDbContext which registers it with scoped lifetime, and add AsNoTracking for read-only queries to improve performance.