aspnet-core
Build, 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, or deployment behavior; deciding between ASP.NET Core sub-stacks. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 515
- Forks
- 41
01 前言 Front Matter
- name
- aspnet-core
- description
- Build, 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, or deployment behavior; deciding between ASP.NET Core sub-stacks. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
- compatibility
- Requires an ASP.NET Core project or solution.
02 资源文件 63
- 其他.gitignore34 B
- 参考文档COMPLETE_GUIDE.md7.3 KB
- 参考文档COMPLETION_REPORT.md9.3 KB
- 参考文档cursor_pi_cli_rpc.md20.9 KB
- 脚本demo.js1.7 KB
- 参考文档docs/issues/20260112-shittycodingagent.ai 真实网站测试.md4.7 KB
- 参考文档docs/issues/20260112-web-browser 技能全面测试.md9.5 KB
- 参考文档docs/pr/20260112-web-browser 技能测试与修复.md10.0 KB
- 脚本examples.js3.2 KB
- 参考文档EXAMPLES.md7.3 KB
- 参考文档FIX_NOTE.md6.1 KB
- 参考文档kwm-full.html175.7 KB
- 许可证LICENSE1.0 KB
- 参考文档manifest.json90 B
- 参考文档package-lock.json33.8 KB
- 参考文档package.json457 B
- 参考文档pnpm-lock.yaml22.4 KB
- 参考文档README.md10.2 KB
- 参考文档references/anti-patterns.md26.8 KB
- 参考文档references/patterns.md29.3 KB
- 参考文档resources.json10 B
- 脚本scripts/browser.sh1.7 KB
- 脚本scripts/check-console.js1.6 KB
- 脚本scripts/check-visible.js1.4 KB
- 脚本scripts/checkbox.js2.4 KB
- 脚本scripts/clear-data.js2.1 KB
- 脚本scripts/click.js1.2 KB
- 脚本scripts/console-logs.js1.7 KB
- 脚本scripts/cookies.js4.3 KB
- 脚本scripts/debug.js2.4 KB
- 脚本scripts/download.js3.1 KB
- 脚本scripts/eval.js2.5 KB
- 脚本scripts/find-text.js3.1 KB
- 脚本scripts/get-element.js2.6 KB
- 脚本scripts/get-meta.js4.0 KB
- 脚本scripts/get-port.js438 B
- 脚本scripts/hover.js1.2 KB
- 脚本scripts/inspect.js3.2 KB
- 脚本scripts/intercept.js3.7 KB
- 脚本scripts/nav.js1.2 KB
- 脚本scripts/network.js4.0 KB
- 脚本scripts/pdf.js1.7 KB
- 脚本scripts/performance.js2.5 KB
- 脚本scripts/pick.js5.5 KB
- 脚本scripts/reload.js1.7 KB
- 脚本scripts/screenshot.js961 B
- 脚本scripts/scroll.js3.0 KB
- 脚本scripts/select.js1.3 KB
- 脚本scripts/start.js5.1 KB
- 脚本scripts/stop.js1.6 KB
- 脚本scripts/storage.js4.3 KB
- 脚本scripts/submit.js1.2 KB
- 脚本scripts/tabs.js3.4 KB
- 脚本scripts/test.js2.1 KB
- 脚本scripts/type.js1.6 KB
- 脚本scripts/upload.js1.5 KB
- 脚本scripts/wait-for-url.js1.6 KB
- 脚本scripts/wait-for.js2.4 KB
- 参考文档SUBAGENT_CREATED.md6.4 KB
- 脚本test-all-scripts.js2.6 KB
- 脚本test-complete.js3.9 KB
- 脚本test-integration.js2.0 KB
- 脚本test-subagent.js3.4 KB
03 SKILL.md 正文
ASP.NET Core
Trigger On
- working on ASP.NET Core apps, services, or middleware
- changing auth, routing, configuration, hosting, or deployment behavior
- deciding between ASP.NET Core sub-stacks such as Blazor, Minimal APIs, or controller APIs
- debugging request pipeline issues
- modernizing legacy ASP.NET to ASP.NET Core
Documentation
- ASP.NET Core Overview
- ASP.NET Core Middleware
- ASP.NET Core Best Practices
- Configuration in ASP.NET Core
- Authentication and Authorization
References
- patterns.md - Detailed middleware patterns, security patterns, configuration patterns, DI patterns, error handling patterns, and logging patterns
- anti-patterns.md - Common ASP.NET Core mistakes including HttpClient misuse, async anti-patterns, configuration errors, DI issues, middleware ordering problems, and security vulnerabilities
Workflow
-
Detect the real hosting shape first:
- top-level
Program.csstructure - middleware order and registration
- auth model (Identity, JWT, OAuth, cookies)
- endpoint registrations and routing
- top-level
-
Follow the correct middleware order:
ExceptionHandler → HttpsRedirection → Static Files → Routing → CORS → Authentication → Authorization → Rate Limiting → Response Caching → Custom Middleware → Endpoints -
Use built-in patterns correctly:
- Prefer
IOptions<T>/IOptionsSnapshot<T>for configuration - Use
ILogger<T>for structured logging - Use
IHttpClientFactoryfor HTTP clients (nevernew HttpClient()) - Use
IHostedService/BackgroundServicefor background work
- Prefer
-
Route specialized work to specific skills:
- UI and components →
blazor - Real-time →
signalr - RPC →
grpc - New HTTP APIs →
minimal-apis(prefer unless controllers needed) - Controller APIs →
web-api
- UI and components →
-
Validate with build, tests, and targeted endpoint checks.
Current Upstream Notes
- ASP.NET Core
v10.0.11is a servicing release rather than a new programming model. It updates OpenAPI to2.7.5, fixes restoration of expired client-persisted Blazor circuit state, and refreshes servicing dependencies. Keep the existing middleware and endpoint architecture, then rerun focused OpenAPI, interactive-rendering, auth, and startup tests. - The August 2026 Microsoft Learn overview for
aspnetcore-10.0remains 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.
Middleware Patterns
Correct Order Matters
var app = builder.Build();
app.UseExceptionHandler("/error"); // 1. Catch all exceptions
app.UseHsts(); // 2. Security headers
app.UseHttpsRedirection(); // 3. HTTPS redirect
app.UseStaticFiles(); // 4. Serve static files
app.UseRouting(); // 5. Route matching
app.UseCors(); // 6. CORS policy
app.UseAuthentication(); // 7. Who are you?
app.UseAuthorization(); // 8. Can you access?
app.UseRateLimiter(); // 9. Rate limiting
app.UseResponseCaching(); // 10. Response cache
app.MapControllers(); // 11. Endpoints
Custom Middleware Pattern
public class RequestTimingMiddleware
{
private readonly RequestDelegate _next;
private readonly ILogger<RequestTimingMiddleware> _logger;
public RequestTimingMiddleware(RequestDelegate next, ILogger<RequestTimingMiddleware> logger)
{
_next = next;
_logger = logger;
}
public async Task InvokeAsync(HttpContext context)
{
var sw = Stopwatch.StartNew();
await _next(context);
_logger.LogInformation("Request {Path} completed in {Elapsed}ms",
context.Request.Path, sw.ElapsedMilliseconds);
}
}
Configuration Patterns
Strongly-Typed Options
// appsettings.json
{
"EmailSettings": {
"SmtpServer": "smtp.example.com",
"Port": 587
}
}
// Registration
builder.Services.Configure<EmailSettings>(
builder.Configuration.GetSection("EmailSettings"));
// Usage
public class EmailService(IOptions<EmailSettings> options)
{
private readonly EmailSettings _settings = options.Value;
}
Environment-Based Configuration
builder.Configuration
.AddJsonFile("appsettings.json", optional: false)
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables()
.AddUserSecrets<Program>(optional: true);
Security Patterns
Authentication Setup
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
ValidIssuer = builder.Configuration["Jwt:Issuer"],
ValidAudience = builder.Configuration["Jwt:Audience"],
IssuerSigningKey = new SymmetricSecurityKey(
Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"]!))
};
});
Authorization Policies
builder.Services.AddAuthorization(options =>
{
options.AddPolicy("AdminOnly", policy =>
policy.RequireRole("Admin"));
options.AddPolicy("MinAge18", policy =>
policy.RequireClaim("Age", "18", "19", "20")); // simplified
});
Anti-Patterns to Avoid
| Anti-Pattern | Why It's Bad | Better Approach |
|---|---|---|
new HttpClient() |
Socket exhaustion | IHttpClientFactory |
Sync-over-async (Task.Result) |
Thread pool starvation | await properly |
Storing secrets in appsettings.json |
Security risk | User Secrets, Key Vault |
| Catching all exceptions silently | Hides bugs | Use IExceptionHandler |
async void in middleware |
Crashes process | async Task |
| Missing HTTPS redirect | Security risk | UseHttpsRedirection() |
Performance Best Practices
- Use async/await everywhere — avoid sync blocking calls
- Pool DbContext properly — use scoped lifetime
- Enable response compression —
UseResponseCompression() - Use output caching —
UseOutputCache()for .NET 7+ - Profile with diagnostic tools — Visual Studio Diagnostic Tools, PerfView
- Avoid allocations in hot paths — use
Span<T>, pooling
Deliver
- production-credible ASP.NET Core code and config
- a clear request pipeline and hosting story
- verification that matches the affected endpoints and middleware
- security headers and HTTPS configured correctly
Validate
- middleware order is intentional and documented
- security and configuration changes are explicit
- endpoint behavior is covered by tests or smoke checks
- no blocking calls in async context
- secrets are not committed to source control
- health checks are implemented for production readiness
04 同仓库更多 Skills
xtwitter-scraper
Use XTwitterScraper when a .NET application needs typed access to Xquik's X automation REST API for tweet search, user lookup, posting workflows, extraction jobs, monitors, webhooks, or giveaway draws. USE FOR: integrating the XTwitterScraper NuGet package; reviewing Xquik API client usage; modeling API-key configuration, pagination, binary exports, raw responses, retries, and webhook/event flows in .NET. DO NOT USE FOR: unrelated stacks; direct browser automation; generic social-media strategy; or code that does not call Xquik. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
sep
Use Sep for high-performance separated-value parsing and writing in .NET, including delimiter inference, explicit parser/writer options, and low-allocation row/column workflows. USE FOR: delimited data needs are performance-sensitive and allocation-aware; project needs explicit control over separator inference, escaping, trimming, and header behavior;. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
webgpu-threejs-tsl
Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.
roslynk
Use Roslynk for semantic inspection and edits of *.cs, *.razor and *.cshtml solution files.
system-text-json-net11
Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in `JsonNamingPolicy.PascalCase` naming policy, and the strongly-typed generic `JsonSerializerOptions.GetTypeInfo` and `JsonSerializerOptions.TryGetTypeInfo` metadata accessors (generic overloads that return a typed `JsonTypeInfo`). USE ONLY when the user is targeting net11.0 or later and needs PascalCase JSON property or dictionary-key names without writing a custom naming policy, a strongly-typed generic `JsonTypeInfo` instead of the non-generic `JsonTypeInfo`, or a no-throw way to probe whether a type's serialization metadata is resolved. DO NOT USE when the target is earlier than net11.0, the requested behavior uses an established pre-net11 naming policy, or the user explicitly selected another JSON library.
process-api-net11
Provides guidance on the new System.Diagnostics.Process APIs introduced in .NET 11: Process.Run, Process.RunAndCaptureText, Process.StartAndForget, Process.ReadAllText/Bytes/Lines, KillOnParentExit, InheritedHandles, and StartDetached. USE FOR: starting, orchestrating, or capturing output from external processes in applications targeting net11.0 or later. DO NOT USE FOR: applications targeting .NET 10 or earlier, or basic pre-.NET 11 Process.Start usage without new APIs.