MapGet associates a URL path with a handler for HTTP GET requests. In a minimal API, the handler generates the response when a matching request arrives; GET should retrieve data without changing server state. section 3.6 section 5.2.2
Return a greeting from the root path
WebApplicationBuilder builder = WebApplication.CreateBuilder(args); WebApplication app = builder.Build(); app.MapGet("/", () => "Hello World!"); app.Run(); This endpoint returns plain text for GET requests to /. The server begins listening only after app.Run(). section 3.6
A MapGet call has two essential parts:
- The first argument is the URL path, such as / or /person/{name}. section 3.6
- The second argument is a delegate that produces the response, optionally using values captured from the route. section 3.6
- Use MapPost or another Map* method when the operation creates, changes, or deletes data. section 5.2.2
Table 5.1 The minimal API map endpoints and the corresponding HTML verbs (view table figure)
| Fetch data only; no modification of state. May be safe to cache. |
||
Compare MapGet with the other minimal API mapping methods and their expected HTTP operations. section 5.2.2


