aspnet-core

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ASP.NET Core

ASP.NET Core

Cross-platform, high-performance framework for building modern web apps.
跨平台、高性能的现代Web应用构建框架。

When to Use

适用场景

  • High-performance APIs (one of the fastest benchmarks)
  • Enterprise applications
  • Microservices
  • Real-time apps (SignalR)
  • 高性能API(基准测试中速度最快的框架之一)
  • 企业级应用
  • 微服务
  • 实时应用(SignalR)

Quick Start

快速开始

csharp
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!");

app.Run();
csharp
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!");

app.Run();

Core Concepts

核心概念

Middleware Pipeline

中间件管道

Request processing pipeline composed of delegates.
由委托组成的请求处理管道。

Dependency Injection

依赖注入

Built-in DI container, a core citizen of the framework.
框架内置的DI容器,是框架的核心组件。

Kestrel

Kestrel

Cross-platform web server for ASP.NET Core.
适用于ASP.NET Core的跨平台Web服务器。

Best Practices

最佳实践

Do:
  • Use the built-in DI
  • Use asynchronous controllers (
    async Task<IActionResult>
    )
  • Use Environment Variables for config settings
Don't:
  • Block asynchronous code (
    .Result
    or
    .Wait()
    )
  • Store large objects in Session state
建议
  • 使用内置的DI容器
  • 使用异步控制器(
    async Task<IActionResult>
  • 使用环境变量存储配置项
不建议
  • 阻塞异步代码(调用
    .Result
    .Wait()
  • 在Session状态中存储大型对象

References

参考资料