liveBook · Manning

HTTP method

As explained in ASP.NET Core in Action, 3e

An HTTP verb is the method token in an HTTP request that indicates the intended operation.

An HTTP method is the verb in a request that states the intended operation on a resource. Requests also carry a path and may include headers and a body; the server uses these details to produce a response. section 1.4.1

Choose the method whose expected meaning matches the operation:

  • GET fetches data without modifying server state and may be cacheable. section 5.2.2
  • POST creates a new resource. section 5.2.2
  • PUT creates or replaces an existing resource, PATCH modifies one, and DELETE removes one. section 5.2.2

Mapping methods in a minimal API

ASP.NET Core minimal APIs map methods to handlers with functions such as MapGet("/person/{name}", handler), MapPost, MapPut, MapPatch, and MapDelete. A browser commonly sends GET when following a link, while a client-side SPA or mobile app can send methods such as POST or DELETE. section 5.2.2

Table 5.1 The minimal API map endpoints and the corresponding HTML verbs (view table figure)

Method

HTTP verb

Expected operation

MapGet(path, handler)

GET

Fetch data only; no modification of state. May be safe to cache.

MapPost(path, handler)

POST

Create a new resource.

MapPut(path, handler)

PUT

Create or replace an existing resource.

MapDelete(path, handler)

DELETE

Delete the given resource.

MapPatch(path, handler)

PATCH

Modify the given resource.

MapMethods(path, methods, handler)

Multiple verbs

Multiple operations.

Map(path, handler)

All verbs

Multiple operations.

MapFallback(handler)

All verbs

Useful for SPA fallback routes.

Use the method-to-operation table to compare minimal API mapping functions with their corresponding HTTP semantics. section 5.2.2

The method also helps ASP.NET Core select behavior. In Razor Pages, the HTTP method combines with an optional handler route value to choose one page handler, such as OnGet, OnPostAsync, or OnDelete. section 15.2

How ASP.NET Core in Action, 3e covers it

How deep it goes
Defines request-level meaning and maps common verbs to handlers, but defers detailed HTTP protocol mechanics.
Examples
Uses browser GET navigation, MapGet routes, method-mapping functions, and Razor handlers named OnGet, OnPostAsync, and OnDelete.
What it assumes
Builds from HTTP request-response basics, including paths, headers, bodies, and server responses.
What you can do after
Apply it via ASP.NET Core minimal APIs and Razor Pages to match requests with appropriate operations or handlers.
How it connects
Connects HTTP requests with RESTful applications, minimal APIs, endpoint routing, and Razor Pages.

Also explained in

Compare how 10 books explain HTTP method →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.