添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

REST APIs with .NET and C#

ASP.NET makes it easy to build services that reach a broad range of clients, including browsers and mobile devices.

With ASP.NET you use the same framework and patterns to build both web pages and services, side-by-side in the same project.

app.MapGet("/people", () => new[] new Person("Ana"), new Person("Filipe"), new Person("Emillia") app.Run(); record Person(string Name);
Terminal
curl https://localhost:5001/people
[{"name":"Ana"},{"name":"Felipe"},{"name":"Emillia"}]

Simple serialization

ASP.NET was designed for modern web experiences. Endpoints automatically serialize your classes to properly formatted JSON out of the box. No special configuration is required. Of course, serialization can be customized for endpoints that have unique requirements.

Authentication and authorization

Secure API endpoints with built-in support for industry standard JSON Web Tokens (JWT). Policy-based authorization gives you the flexibility to define powerful access control rules—all in code.

Learn more about ASP.NET security
Terminal
curl -H "Content-Type: application/json" -X POST -d "{'name':'Ana'}" https://localhost:5001/people/create -i
HTTP/2 202
// MapGroup organizes groups of endpoints under "people" var group = app.MapGroup("/people"); group.MapGet("/", async (PersonContext db) => return await db.Person.ToListAsync(); group.MapGet("/{id}", async (int id, PersonContext db) => return await db.Person.FindAsync(id); group.MapPost("/create", async (Person person, PersonContext db) => db.Person.Add(person); await db.SaveChangesAsync(); return Results.Created($"/people/{person.Id}", person); app.Run();

Routing alongside your code

ASP.NET lets you define routes and verbs inline with your code, using attributes. Data from the request path, query string, and request body are automatically bound to method parameters.

Learn more about routing in ASP.NET

Designed with security in mind

You don't deploy your apps without security, so why test them without security? ASP.NET provides first class support for HTTPS out of the box. Automatically generate a test certificate and easily import it to enable local HTTPS so you run, and debug, your apps the way they are intended to be... secured.

Easily integrate with Power Platform

Using Power Apps , anyone can build professional-grade business applications with low-code. Extend Power Apps further as a professional developer with custom connectors and logic. Learn how to build these services using OpenAPI-enabled ASP.NET Web APIs and make them available to Power Apps creators.

Learn about using web APIs with Power Apps

Great tools for any platform

Build, debug, and deploy from any platform to any platform.

Issues in production? Not a problem... simply attach the debugger to your production instance and debug from your laptop!

Learn about .NET tools

Start building APIs with ASP.NET Core

Our beginner's guide to building APIs with ASP.NET Core is designed to provide you with the foundation you need to start building APIs with .NET in a collection of short, pragmatic videos.

Browse all videos

Our step-by-step tutorial will help you get APIs with ASP.NET Core running on your computer.

Get started