编程

aspnet-core

试用

基于微软官方文档,获得正确的 ASP.NET Core 实现方案。

它能做什么

该技能指导你构建、审查、重构或架构 ASP.NET Core 应用。它提供结构化的工作流程和参考文档,涵盖 Blazor Web Apps、Razor Pages、MVC、Minimal APIs、基于控制器的 Web API、SignalR、gRPC、中间件、依赖注入、配置、认证、授权、测试、性能和部署。优先使用 `WebApplicationBuilder`/`WebApplication` 等现代模式,优先使用内置框架功能而非第三方库,并遵循微软官方文档中的约定。

什么时候用它

  • 从零启动新 ASP.NET Core 项目并选择合适的应用模型
  • 审查或重构现有 ASP.NET Core 代码
  • 实现认证、授权或安全相关功能
  • ASP.NET Core 版本升级或迁移

技能文档

ASP.NET Core

Overview

Choose the right ASP.NET Core application model, compose the host and request pipeline correctly, and implement features in the framework style Microsoft documents today.

Load the smallest set of references that fits the task. Do not load every reference by default.

Workflow

  1. Confirm the target framework, SDK, and current app model.
  2. Open references/stack-selection.md first for new apps or major refactors.
  3. Open references/program-and-pipeline.md next for Program.cs, DI, configuration, middleware, routing, logging, and static assets.
  4. Open exactly one primary app-model reference:
    • references/ui-blazor.md
    • references/ui-razor-pages.md
    • references/ui-mvc.md
    • references/apis-minimal-and-controllers.md
  5. Add cross-cutting references only as needed:
    • references/data-state-and-services.md
    • references/security-and-identity.md
    • references/realtime-grpc-and-background-work.md
    • references/testing-performance-and-operations.md
  6. Open references/versioning-and-upgrades.md before introducing new platform APIs into an older solution or when migrating between major versions.
  7. Use references/source-map.md when you need the Microsoft Learn section that corresponds to a task not already covered by the focused references.

Default Operating Assumptions

  • Prefer the latest stable ASP.NET Core and .NET unless the repository or user request pins an older target.
  • As of March 2026, prefer .NET 10 / ASP.NET Core 10 for new production work. Treat ASP.NET Core 11 as preview unless the user explicitly asks for preview features.
  • Prefer WebApplicationBuilder and WebApplication. Avoid older Startup and WebHost patterns unless the codebase already uses them or the task is migration.
  • Prefer built-in DI, options/configuration, logging, ProblemDetails, OpenAPI, health checks, rate limiting, output caching, and Identity before adding third-party infrastructure.
  • Keep feature slices cohesive so the page, component, endpoint, controller, validation, service, data access, and tests are easy to trace.
  • Respect the existing app model. Do not rewrite Razor Pages to MVC or controllers to Minimal APIs without a clear reason.

Reference Guide

  • references/_sections.md: Quick index and reading order.
  • references/stack-selection.md: Choose the right ASP.NET Core application model and template.
  • references/program-and-pipeline.md: Structure Program.cs, services, middleware, routing, configuration, logging, and static assets.
  • references/ui-blazor.md: Build Blazor Web Apps, choose render modes, and use components, forms, and JS interop correctly.
  • references/ui-razor-pages.md: Build page-focused server-rendered apps with handlers, model binding, and conventions.
  • references/ui-mvc.md: Build controller/view applications with clear separation of concerns.
  • references/apis-minimal-and-controllers.md: Build HTTP APIs with Minimal APIs or controllers, including validation and response patterns.
  • references/data-state-and-services.md: Use EF Core, DbContext, options, IHttpClientFactory, session, temp data, and app state responsibly.
  • references/security-and-identity.md: Apply authentication, authorization, Identity, secrets, data protection, CORS, CSRF, and HTTPS guidance.
  • references/realtime-grpc-and-background-work.md: Use SignalR, gRPC, and hosted services.
  • references/testing-performance-and-operations.md: Add integration tests, browser tests, caching, compression, health checks, rate limits, and deployment concerns.
  • references/versioning-and-upgrades.md: Handle target frameworks, breaking changes, obsolete APIs, and migrations.
  • references/source-map.md: Map the official ASP.NET Core documentation tree to the references in this skill.

Execution Notes

  • When generating new code, start from the correct dotnet new template and keep the generated structure recognizable.
  • When editing an existing solution, follow the solution's conventions first and use these references to avoid framework misuse or outdated patterns.
  • When a task mentions "latest", verify the feature on Microsoft Learn or the ASP.NET Core docs repo before relying on memory.

常见问题

该技能遵循什么模式和约定?
它遵循微软当前文档中的约定。优先使用 `WebApplicationBuilder`/`WebApplication`,而非旧的 `Startup` 模式;优先使用内置功能(DI、配置、日志、ProblemDetails、OpenAPI、健康检查等),在确实需要时才引入第三方库。
如何帮助选择合适的应用模型?
技能中包含专门的参考指南,帮助在 Blazor Web Apps、Razor Pages、MVC 或 API 方案之间根据场景做出选择。选定后还有针对各模型的详细参考文档。
能处理已有项目的升级吗?
可以。技能中包含版本和升级参考文档,处理目标框架、破坏性变更和迁移场景。编辑现有代码时会尊重既有约定,不会无缘无故地进行重写。

相关技能

诊断生产力系统反复失效的根因,给出最小干预——容量测算、瓶颈定位、可靠的本地记录。

作者 Iván855 次安装69 星标

按用户明确指令,在得到大脑(Get笔记)中保存、搜索并管理笔记与知识库。

作者 iswalle767 次安装66 星标

figma-use

官方

在 Figma 文件内直接执行 JavaScript —— 以编程方式创建节点、设置变量、构建组件、修改布局。

作者 OpenAI27.9k 星标

从 API 文档、SDK 或本地脚本构建可复用的命令行工具,安装后可在任意目录下运行。

作者 OpenAI27.9k 星标

基于p5.js的生成式艺术引擎,支持种子随机性和交互式参数探索,每次运行生成独特的算法视觉作品。

作者 Anthropic179.8k 星标

通过结构化评估和迭代改进来构建和测试新的 AI 技能。

作者 Anthropic179.8k 星标

OpenAI 的更多技能

浏览全部技能

以文档优先的工作流搭建 ChatGPT Apps SDK 项目,从工具规划到可运行的 MCP 服务和组件代码。

作者 OpenAI27.9k 星标

基于团队已有的设计系统组件和 token,在 Figma 中生成或更新完整页面。

作者 OpenAI27.9k 星标

从代码构建 Figma 设计系统,遵循正确的构建顺序——变量、组件、主题、文档依次推进。

作者 OpenAI27.9k 星标

figma-use

官方

在 Figma 文件内直接执行 JavaScript —— 以编程方式创建节点、设置变量、构建组件、修改布局。

作者 OpenAI27.9k 星标

hatch-pet

官方

从概念、品牌线索或参考图生成 Codex 兼容的动画宠物图集,含 QA 和打包输出

作者 OpenAI27.9k 星标

imagegen

官方

根据文本描述生成或编辑位图图像,标准模式无需 API 密钥。

作者 OpenAI27.9k 星标