You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/tutorials/first-mongo-app.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ description: This tutorial demonstrates how to create an ASP.NET Core web API us
6
6
monikerRange: '>= aspnetcore-3.1'
7
7
ms.author: wpickett
8
8
ms.custom: mvc, sfi-ropc-nochange
9
-
ms.date: 05/04/2026
9
+
ms.date: 05/06/2026
10
10
uid: tutorials/first-mongo-app
11
11
---
12
12
# Create a web API with ASP.NET Core and MongoDB
@@ -50,17 +50,17 @@ Enable MongoDB and MongoDB Shell access from anywhere on the development machine
50
50
51
51
1. Download and Install MongoDB Shell:
52
52
* macOS/Linux: Choose a directory to extract the MongoDB Shell to. Add the resulting path for `mongosh` to the `PATH` environment variable.
53
-
* Windows: MongoDB Shell (mongosh.exe) is installed at *C:\\Users\\\<user>\\AppData\\Local\\Programs\\mongosh*. Add the resulting path for `mongosh.exe` to the `PATH` environment variable.
53
+
* Windows: MongoDB Shell (mongosh.exe) is installed at *C:\\Users\\{USER NAME}\\AppData\\Local\\Programs\\mongosh*. Add the resulting path for `mongosh.exe` to the `PATH` environment variable.
54
54
1. Download and Install MongoDB:
55
55
* macOS/Linux: Verify the directory that MongoDB was installed at, usually in */usr/local/mongodb*. Add the resulting path for `mongodb` to the `PATH` environment variable.
56
-
* Windows: MongoDB is installed at *C:\\Program Files\\MongoDB* by default. Add *C:\\Program Files\\MongoDB\\Server\\\<version_number>\\bin* to the `PATH` environment variable.
56
+
* Windows: MongoDB is installed at *C:\\Program Files\\MongoDB* by default. Add *C:\\Program Files\\MongoDB\\Server\\{VERSION NUMBER}\\bin* to the `PATH` environment variable.
57
57
1. Choose a Data Storage Directory: Select a directory on your development machine for storing data. Create the directory if it doesn't exist. The MongoDB Shell doesn't create new directories:
58
58
* macOS/Linux: For example, `/usr/local/var/mongodb`.
59
59
* Windows: For example, `C:\\BooksData`.
60
-
1. In the OS command shell (not the MongoDB Shell), use the following command to connect to MongoDB on default port 27017. Replace `<data_directory_path>` with the directory chosen in the previous step.
60
+
1. In the OS command shell (not the MongoDB Shell), use the following command to connect to MongoDB on default port 27017. Replace `{DATA DIRECTORY PATH}` with the directory chosen in the previous step.
61
61
62
62
```console
63
-
mongod --dbpath <data_directory_path>
63
+
mongod --dbpath {DATA DIRECTORY PATH}
64
64
```
65
65
66
66
Use the previously installed MongoDB Shell in the following steps to create a database, make collections, and store documents. For more information on MongoDB Shell commands, see [`mongosh`](https://docs.mongodb.com/mongodb-shell/run-commands/).
@@ -304,7 +304,7 @@ This tutorial uses [Endpoints Explorer and .http files](xref:test/http-files#use
304
304
If this is the first time that a request is generated, the file is created in the project root.
@@ -450,13 +450,13 @@ In `Program.cs`, add the following highlighted code:
450
450
The previous code enables the Swagger middleware for serving the generated JSON document using the Swagger UI. Swagger is only enabled in a development environment. Enabling Swagger in a production environment could expose potentially sensitive details about the API's structure and implementation.
451
451
452
452
The app uses the OpenAPI document generated by OpenApi, located at `/openapi/v1.json`, to generate the UI.
453
-
View the generated OpenAPI specification for the `BookStoreApi` API while the project is running by navigating to `https://localhost:<port>/openapi/v1.json` in your browser.
453
+
View the generated OpenAPI specification for the `BookStoreApi` API while the project is running by navigating to `https://localhost:{PORT}/openapi/v1.json` in your browser.
454
454
455
455
The OpenAPI specification is a document in JSON format that describes the structure and capabilities of your API, including endpoints, request/response formats, parameters, and more. It's essentially a blueprint of your API that can be used by various tools to understand and interact with your API.
456
456
457
457
1. Build and run the app.
458
458
459
-
1. Navigate to `https://localhost:<port>/swagger` in your browser. Swagger provides a UI to test all the API endpoints based on the OpenAPI document.
459
+
1. Navigate to `https://localhost:{PORT}/swagger` in your browser. Swagger provides a UI to test all the API endpoints based on the OpenAPI document.
460
460
461
461
1. Expand the **GET /books** endpoint and click the **Try it out** button.
0 commit comments