Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aspnetcore/includes/net-prereqs-vs-10-latest.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) with the **ASP.NET and web development** workload.

![VS22 installer workloads](~/tutorials/min-web-api/_static/asp-net-web-dev.png)
![VS22 installer workloads](~/tutorials/min-web-api/static/asp-net-web-dev.png)
2 changes: 1 addition & 1 deletion aspnetcore/includes/net-prereqs-vs-10.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* [The latest version of Visual Studio](https://visualstudio.microsoft.com/downloads/) with the **ASP.NET and web development** workload.

:::image type="content" source="~/tutorials/min-web-api/_static/asp-net-web-dev-2026.png" alt-text="VS26 installer workloads" lightbox="~/tutorials/min-web-api/_static/asp-net-web-dev-2026.png":::
:::image type="content" source="~/tutorials/min-web-api/static/asp-net-web-dev-2026.png" alt-text="VS26 installer workloads" lightbox="~/tutorials/min-web-api/static/asp-net-web-dev-2026.png":::
2 changes: 1 addition & 1 deletion aspnetcore/includes/net-prereqs-vs-11-latest.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* [Visual Studio](https://visualstudio.microsoft.com/downloads/) with the **ASP.NET and web development** workload.

![VS22 installer workloads](~/tutorials/min-web-api/_static/asp-net-web-dev.png)
![VS22 installer workloads](~/tutorials/min-web-api/static/asp-net-web-dev.png)
2 changes: 1 addition & 1 deletion aspnetcore/includes/net-prereqs-vs-7.0.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

* [Visual Studio 2022](https://visualstudio.microsoft.com/vs/#download) with the **ASP.NET and web development** workload.

![VS22 installer workloads](~/tutorials/min-web-api/_static/asp-net-web-dev.png)
![VS22 installer workloads](~/tutorials/min-web-api/static/asp-net-web-dev.png)
2 changes: 1 addition & 1 deletion aspnetcore/includes/net-prereqs-vs-8.0.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

* [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) with the **ASP.NET and web development** workload.

![VS22 installer workloads](~/tutorials/min-web-api/_static/asp-net-web-dev.png)
![VS22 installer workloads](~/tutorials/min-web-api/static/asp-net-web-dev.png)
2 changes: 1 addition & 1 deletion aspnetcore/includes/net-prereqs-vs-9.0.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- use the include for articles that are not updated every release, like the data/ef articles -->
* [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) with the **ASP.NET and web development** workload.

![VS22 installer workloads](~/tutorials/min-web-api/_static/asp-net-web-dev.png)
![VS22 installer workloads](~/tutorials/min-web-api/static/asp-net-web-dev.png)
2 changes: 1 addition & 1 deletion aspnetcore/includes/net-prereqs-vs-latest.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) with the **ASP.NET and web development** workload.

![VS22 installer workloads](~/tutorials/min-web-api/_static/asp-net-web-dev.png)
![VS22 installer workloads](~/tutorials/min-web-api/static/asp-net-web-dev.png)
40 changes: 20 additions & 20 deletions aspnetcore/tutorials/min-web-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ author: wadepickett
description: Learn how to build a minimal API with ASP.NET Core.
ai-usage: ai-assisted
ms.author: wpickett
ms.custom: engagement-fy24
ms.date: 02/12/2026
ms.date: 06/03/2026
monikerRange: '>= aspnetcore-6.0'
uid: tutorials/min-web-api
---
Expand All @@ -15,9 +14,9 @@ uid: tutorials/min-web-api
[!INCLUDE[](~/includes/not-latest-version.md)]

<!-- TODO: Remove aspnetcore\tutorials\min-web-api\samples\6.x -->
By [Rick Anderson](https://twitter.com/RickAndMSFT) and [Tom Dykstra](https://github.com/tdykstra)
By [Wade Pickett](https://github.com/wadepickett) and [Tom Dykstra](https://github.com/tdykstra)
Comment thread
wadepickett marked this conversation as resolved.

:::moniker range=">= aspnetcore-9.0"
:::moniker range=">= aspnetcore-10.0"

Minimal APIs are architected to create HTTP APIs with minimal dependencies. They're ideal for microservices and apps that want to include only the minimum files, features, and dependencies in ASP.NET Core.

Expand All @@ -41,32 +40,32 @@ This tutorial creates the following API:

# [Visual Studio](#tab/visual-studio)

[!INCLUDE[](~/includes/net-prereqs-vs-9.0.md)]
[!INCLUDE[](~/includes/net-prereqs-vs-10.md)]

# [Visual Studio Code](#tab/visual-studio-code)

[!INCLUDE[](~/includes/net-prereqs-vsc-9.0.md)]
[!INCLUDE[](~/includes/net-prereqs-vsc-10.0.md)]

---

## Create an API project

# [Visual Studio](#tab/visual-studio)

* Start Visual Studio 2022 and select **Create a new project**.
* Start Visual Studio 2026 and select **Create a new project**.
* In the **Create a new project** dialog:
* Enter `Empty` in the **Search for templates** search box.
* Select the **ASP.NET Core Empty** template and select **Next**.

![Visual Studio Create a new project](~/tutorials/min-web-api/_static/9.x/create-new-project-empty-vs17.11.0.png)
![Visual Studio Create a new project](~/tutorials/min-web-api/static/10/create-new-project-empty-vs18-6-2.png)

* Name the project *TodoApi* and select **Next**.
* In the **Additional information** dialog:
* Select **.NET 9.0**
* Select **.NET 10.0 (Long Term Support)**
* Uncheck **Do not use top-level statements**
* Select **Create**

![Additional information](~/tutorials/min-web-api/_static/9.x/add-info-vs17.11.0.png)
![Additional information](~/tutorials/min-web-api/static/10/add-info-vs18-6-2.png)

# [Visual Studio Code](#tab/visual-studio-code)

Expand Down Expand Up @@ -136,7 +135,6 @@ NuGet packages must be added to support the database and diagnostics used in thi

* From the **Tools** menu, select **NuGet Package Manager > Manage NuGet Packages for Solution**.
* Select the **Browse** tab.
* Select **Include Prelease**.
* Enter **Microsoft.EntityFrameworkCore.InMemory** in the search box, and then select `Microsoft.EntityFrameworkCore.InMemory`.
* Select the **Project** checkbox in the right pane and then select **Install**.
* Follow the preceding instructions to add the `Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore` package.
Expand Down Expand Up @@ -184,7 +182,7 @@ This tutorial uses [Endpoints Explorer and .http files](xref:test/http-files#use

# [Visual Studio Code](#tab/visual-studio-code)

## Create API testing UI with Swagger
## Test the web API

There are many available web API testing tools to choose from, and you can follow this tutorial's introductory API test steps with your own preferred tool.

Expand All @@ -205,6 +203,7 @@ For more information on using OpenAPI and NSwag with ASP.NET, see <xref:tutorial
```

The previous command adds the [NSwag.AspNetCore](https://www.nuget.org/packages/NSwag.AspNetCore/) package, which contains tools to generate Swagger documents and UI.
This project is using OpenAPI, so the NSwag package is only used to generate the Swagger UI.

### Configure Swagger middleware

Expand Down Expand Up @@ -242,7 +241,7 @@ The POST endpoint will be used to add data to the app.
* Select **View** > **Other Windows** > **Endpoints Explorer**.
* Right-click the **POST** endpoint and select **Generate request**.

![Endpoints Explorer context menu highlighting Generate Request menu item.](~/tutorials/min-web-api/_static/9.x/generate-request-vs17.8.0.png)
![Endpoints Explorer context menu highlighting Generate Request menu item.](~/tutorials/min-web-api/static/9.x/generate-request-vs17.8.0.png)

A new file is created in the project folder named `TodoApi.http`, with contents similar to the following example:

Expand Down Expand Up @@ -289,17 +288,17 @@ The POST endpoint will be used to add data to the app.

* Select the **Send request** link that is above the `POST` request line.

![.http file window with run link highlighted.](~/tutorials/min-web-api/_static/9.x/http-file-run-button-vs17.8.0.png)
![.http file window with run link highlighted.](~/tutorials/min-web-api/static/9.x/http-file-run-button-vs17.8.0.png)

The POST request is sent to the app and the response is displayed in the **Response** pane.

![.http file window with response from the POST request.](~/tutorials/min-web-api/_static/9.x/http-file-window-with-response-vs17.8.0.png)
![.http file window with response from the POST request.](~/tutorials/min-web-api/static/9.x/http-file-window-with-response-vs17.8.0.png)

# [Visual Studio Code](#tab/visual-studio-code)

* With the app still running, in the browser, navigate to `https://localhost:<port>/swagger` to display the API testing page generated by Swagger.

![Swagger generated API testing page](~/tutorials/min-web-api/_static/9.x/swagger.png)
![Swagger generated API testing page](~/tutorials/min-web-api/static/9.x/swagger.png)

* On the Swagger API testing page, select **Post /todoitems** > **Try it out**.
* Note that the **Request body** field contains a generated example format reflecting the parameters for the API.
Expand All @@ -314,11 +313,11 @@ The POST endpoint will be used to add data to the app.

* Select **Execute**.

![Swagger with Post request](~/tutorials/min-web-api/_static/9.x/swagger-post-1.png)
![Swagger with Post request](~/tutorials/min-web-api/static/9.x/swagger-post-1.png)

Swagger provides a **Responses** pane below the **Execute** button.

![Swagger with Post resonse](~/tutorials/min-web-api/_static/9.x/swagger-post-responses.png)
![Swagger with Post response](~/tutorials/min-web-api/static/9.x/swagger-post-responses.png)

Note a few of the useful details:

Expand Down Expand Up @@ -753,5 +752,6 @@ See <xref:fundamentals/minimal-apis>

:::moniker-end

[!INCLUDE[](~/tutorials/min-web-api/includes/min-web-api6-7.md)]
[!INCLUDE[](~/tutorials/min-web-api/includes/min-web-api8.md)]
[!INCLUDE[](~/tutorials/min-web-api/includes/min-web-api-6-7.md)]
[!INCLUDE[](~/tutorials/min-web-api/includes/min-web-api-8.md)]
[!INCLUDE[](~/tutorials/min-web-api/includes/min-web-api-9.md)]
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ This tutorial creates the following API:
* Enter `Empty` in the **Search for templates** search box.
* Select the **ASP.NET Core Empty** template and select **Next**.

![Visual Studio Create a new project](~/tutorials/min-web-api/_static/empty.png)
![Visual Studio Create a new project](~/tutorials/min-web-api/static/empty.png)

* Name the project *TodoApi* and select **Next**.
* In the **Additional information** dialog:
* Select **.NET 7.0**
* Uncheck **Do not use top-level statements**
* Select **Create**

![Additional information](~/tutorials/min-web-api/_static/add-info7.png)
![Additional information](~/tutorials/min-web-api/static/add-info7.png)

# [Visual Studio Code](#tab/visual-studio-code)

Expand Down Expand Up @@ -202,7 +202,7 @@ The POST endpoint will be used to add data to the app.

* With the app still running, in the browser, navigate to `https://localhost:<port>/swagger` to display the API testing page generated by Swagger.

![Swagger generated API testing page](~/tutorials/min-web-api/_static/8.x/swagger.png)
![Swagger generated API testing page](~/tutorials/min-web-api/static/8.x/swagger.png)

* On the Swagger API testing page, select **Post /todoitems** > **Try it out**.
* Note that the **Request body** field contains a generated example format reflecting the parameters for the API.
Expand All @@ -217,11 +217,11 @@ The POST endpoint will be used to add data to the app.

* Select **Execute**.

![Swagger with Post](~/tutorials/min-web-api/_static/8.x/swagger-post-1.png)
![Swagger with Post](~/tutorials/min-web-api/static/8.x/swagger-post-1.png)

Swagger provides a **Responses** pane below the **Execute** button.

![Swagger with Post response](~/tutorials/min-web-api/_static/8.x/swagger-post-responses.png)
![Swagger with Post response](~/tutorials/min-web-api/static/8.x/swagger-post-responses.png)

Note a few of the useful details:

Expand Down Expand Up @@ -535,7 +535,7 @@ This tutorial creates the following API:
* Enter `Empty` in the **Search for templates** search box.
* Select the **ASP.NET Core Empty** template and select **Next**.

![Visual Studio Create a new project](~/tutorials/min-web-api/_static/empty.png)
![Visual Studio Create a new project](~/tutorials/min-web-api/static/empty.png)

* Name the project *TodoApi* and select **Next**.
* In the **Additional information** dialog:
Expand Down Expand Up @@ -700,7 +700,7 @@ The POST endpoint will be used to add data to the app.

* With the app still running, in the browser, navigate to `https://localhost:<port>/swagger` to display the API testing page generated by Swagger.

![Swagger generated API testing page](~/tutorials/min-web-api/_static/8.x/swagger.png)
![Swagger generated API testing page](~/tutorials/min-web-api/static/8.x/swagger.png)

* On the Swagger API testing page, select **Post /todoitems** > **Try it out**.
* Note that the **Request body** field contains a generated example format reflecting the parameters for the API.
Expand All @@ -715,11 +715,11 @@ The POST endpoint will be used to add data to the app.

* Select **Execute**.

![Swagger with Post data](~/tutorials/min-web-api/_static/8.x/swagger-post-1.png)
![Swagger with Post data](~/tutorials/min-web-api/static/8.x/swagger-post-1.png)

Swagger provides a **Responses** pane below the **Execute** button.

![Swagger with Post resonse pane](~/tutorials/min-web-api/_static/8.x/swagger-post-responses.png)
![Swagger with Post resonse pane](~/tutorials/min-web-api/static/8.x/swagger-post-responses.png)

Note a few of the useful details:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ This tutorial creates the following API:
* Enter `Empty` in the **Search for templates** search box.
* Select the **ASP.NET Core Empty** template and select **Next**.

![Visual Studio Create a new project](~/tutorials/min-web-api/_static/8.x/create-new-project-empty-vs17.8.0.png)
![Visual Studio Create a new project](~/tutorials/min-web-api/static/8.x/create-new-project-empty-vs17.8.0.png)

* Name the project *TodoApi* and select **Next**.
* In the **Additional information** dialog:
* Select **.NET 8.0 (Long Term Support)**
* Uncheck **Do not use top-level statements**
* Select **Create**

![Additional information](~/tutorials/min-web-api/_static/8.x/add-info-vs17.9.0.png)
![Additional information](~/tutorials/min-web-api/static/8.x/add-info-vs17.9.0.png)

# [Visual Studio Code](#tab/visual-studio-code)

Expand Down Expand Up @@ -222,7 +222,7 @@ The POST endpoint will be used to add data to the app.
* Select **View** > **Other Windows** > **Endpoints Explorer**.
* Right-click the **POST** endpoint and select **Generate request**.

![Endpoints Explorer context menu highlighting Generate Request menu item.](~/tutorials/min-web-api/_static/8.x/generate-request-vs17.8.0.png)
![Endpoints Explorer context menu highlighting Generate Request menu item.](~/tutorials/min-web-api/static/8.x/generate-request-vs17.8.0.png)

A new file is created in the project folder named `TodoApi.http`, with contents similar to the following example:

Expand Down Expand Up @@ -269,17 +269,17 @@ The POST endpoint will be used to add data to the app.

* Select the **Send request** link that is above the `POST` request line.

![.http file window with run link highlighted.](~/tutorials/min-web-api/_static/8.x/http-file-run-button-vs17.8.0.png)
![.http file window with run link highlighted.](~/tutorials/min-web-api/static/8.x/http-file-run-button-vs17.8.0.png)

The POST request is sent to the app and the response is displayed in the **Response** pane.

![.http file window with response from the POST request.](~/tutorials/min-web-api/_static/8.x/http-file-window-with-response-vs17.8.0.png)
![.http file window with response from the POST request.](~/tutorials/min-web-api/static/8.x/http-file-window-with-response-vs17.8.0.png)

# [Visual Studio Code](#tab/visual-studio-code)

* With the app still running, in the browser, navigate to `https://localhost:<port>/swagger` to display the API testing page generated by Swagger.

![Swagger generated API testing page](~/tutorials/min-web-api/_static/8.x/swagger.png)
![Swagger generated API testing page](~/tutorials/min-web-api/static/8.x/swagger.png)

* On the Swagger API testing page, select **Post /todoitems** > **Try it out**.
* Note that the **Request body** field contains a generated example format reflecting the parameters for the API.
Expand All @@ -294,11 +294,11 @@ The POST endpoint will be used to add data to the app.

* Select **Execute**.

![Swagger with Post request](~/tutorials/min-web-api/_static/8.x/swagger-post-1.png)
![Swagger with Post request](~/tutorials/min-web-api/static/8.x/swagger-post-1.png)

Swagger provides a **Responses** pane below the **Execute** button.

![Swagger with Post resonse](~/tutorials/min-web-api/_static/8.x/swagger-post-responses.png)
![Swagger with Post resonse](~/tutorials/min-web-api/static/8.x/swagger-post-responses.png)

Note a few of the useful details:

Expand Down
Loading
Loading