aspnet-core

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

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.
选择合适的ASP.NET Core应用模型,正确配置主机和请求管道,按照微软当前官方文档推荐的框架风格实现功能。
引入满足任务需求的最小引用集,不要默认加载所有引用。

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.
  1. 确认目标框架、SDK和当前使用的应用模型。
  2. 新建应用或进行大规模重构时,首先打开references/stack-selection.md查阅。
  3. 接下来打开references/program-and-pipeline.md,查阅
    Program.cs
    、DI、配置、中间件、路由、日志和静态资源相关内容。
  4. 仅打开一个主应用模型参考文档:
    • references/ui-blazor.md
    • references/ui-razor-pages.md
    • references/ui-mvc.md
    • references/apis-minimal-and-controllers.md
  5. 仅在需要时引入跨领域参考文档:
    • 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. 在旧解决方案中引入新的平台API或在主要版本之间迁移时,先打开references/versioning-and-upgrades.md查阅。
  7. 当你需要查找当前聚焦参考文档未覆盖的任务对应的Microsoft Learn章节时,使用references/source-map.md

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.
  • 除非代码仓库或用户需求指定了旧目标版本,否则优先使用最新稳定版ASP.NET Core和.NET。
  • 截至2026年3月,新生产环境项目优先使用.NET 10 / ASP.NET Core 10。除非用户明确要求预览功能,否则将ASP.NET Core 11视为预览版本。
  • 优先使用
    WebApplicationBuilder
    WebApplication
    。避免使用旧的
    Startup
    WebHost
    模式,除非代码库已经在使用它们或任务是迁移相关的。
  • 在引入第三方基础设施之前,优先使用内置的DI、选项/配置、日志、ProblemDetails、OpenAPI、健康检查、限流、输出缓存和Identity。
  • 保持功能切片的内聚性,以便页面、组件、端点、控制器、验证、服务、数据访问和测试易于追踪。
  • 尊重现有的应用模型。没有明确理由的情况下,不要将Razor Pages重写为MVC,也不要将控制器重写为Minimal APIs。

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.
  • references/_sections.md: 快速索引和阅读顺序。
  • references/stack-selection.md: 选择合适的ASP.NET Core应用模型和模板。
  • references/program-and-pipeline.md: 配置
    Program.cs
    、服务、中间件、路由、日志和静态资源的结构。
  • references/ui-blazor.md: 构建Blazor Web Apps,选择渲染模式,正确使用组件、表单和JS互操作。
  • references/ui-razor-pages.md: 使用处理程序、模型绑定和约定构建以页面为中心的服务端渲染应用。
  • references/ui-mvc.md: 构建具有清晰关注点分离的控制器/视图应用。
  • references/apis-minimal-and-controllers.md: 使用Minimal APIs或控制器构建HTTP APIs,包括验证和响应模式。
  • references/data-state-and-services.md: 合理使用EF Core、
    DbContext
    、选项、
    IHttpClientFactory
    、会话、临时数据和应用状态。
  • references/security-and-identity.md: 应用认证、授权、Identity、密钥、数据保护、CORS、CSRF和HTTPS相关指南。
  • references/realtime-grpc-and-background-work.md: 使用SignalR、gRPC和托管服务。
  • references/testing-performance-and-operations.md: 添加集成测试、浏览器测试、缓存、压缩、健康检查、限流和部署相关注意事项。
  • references/versioning-and-upgrades.md: 处理目标框架、破坏性变更、废弃API和迁移。
  • references/source-map.md: 将官方ASP.NET Core文档结构映射到本技能中的参考内容。

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.
  • 生成新代码时,从正确的
    dotnet new
    模板开始,保持生成的结构易于识别。
  • 编辑现有解决方案时,首先遵循解决方案的约定,使用这些参考文档避免框架误用或使用过时模式。
  • 当任务提到「最新」时,先在Microsoft Learn或ASP.NET Core文档仓库中验证相关功能,不要仅凭记忆处理。