Skip to content

Conversation

@timdeschryver
Copy link
Contributor

@timdeschryver timdeschryver commented Apr 7, 2025

Fixes #35134
Fixes #35133
Fixes #35131
Fixes invalid path


Internal previews

📄 File 🔗 Preview link
aspnetcore/tutorials/first-mongo-app.md Create a web API with ASP.NET Core and MongoDB

1. Download and Install MongoDB Shell:
* macOS/Linux: Choose a directory to extract the MongoDB Shell to. Add the resulting path for `mongosh` to the `PATH` environment variable.
* 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.
* 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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds extra \ to escape the path backslashes.
This fixes an invalid path in the docs (there should be a backslash between users and ):

image

1. Build and run the app.

1. Navigate to `https://localhost:<port>/api/books`, where `<port>` is the automatically assigned port number for the app, to test the controller's parameterless `Get` action method, select **Try it out** > **Execute**. A JSON response similar to the following is displayed:
1. Navigate to `https://localhost:<port>/api/books`, where `<port>` is the automatically assigned port number for the app, to test the controller's parameterless `Get` action method. A JSON response similar to the following is displayed:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wadepickett in #32353 you explicitly added this text.
Should the docs be updates to include the OpenAPI test pages (e.g. swagger, or maybe using http files)?

I don't think this will add much to the docs, as the testing the api part only verifies retrieving the data.

Copy link
Contributor

@wadepickett wadepickett Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went back and forth on this last time we updated since it would add several steps to the tutorial and yet the json returned in the current minimal step is fairly clear and focus of the tutorial is quickly getting ASP.NET Core and MongoDB going. The more I add beyond what is minimally needed for the goal, the more we start to lose people before they get to the last sections beyond testing. For myself, I'm good with longer tutorials. But I follow the data and response too.

That said, you could follow the same Endpoints Explorer .http files for VS and swagger UI for VS Code approach from the [Create a controller-based web API tutorial)[https://review.learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-9.0&branch=pr-en-us-35163&tabs=visual-studio]. I think that would be nice.

Then I will keep a watch on how folks react and where they drop off the topic.

## Additional resources

* [View or download sample code](https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/tutorials/first-mongo-app/samples) ([how to download](xref:index#how-to-download-a-sample))
* [View or download sample code](https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/tutorials/first-mongo-app/samples/8.x/BookStoreApi) ([how to download](xref:index#how-to-download-a-sample))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no 9.x version of the docs. If desired I can create them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. If you want to that's great. This topic is on my list of many that need an update. You could update it afterwards in a new PR or this one. Up to you.

@wadepickett
Copy link
Contributor

Thanks so much @timdeschryver! I will be on this review in about an hour after I get out of some meetings.

Copy link
Contributor

@wadepickett wadepickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timdeschryver, this looks great! Well done!

You asked about adding the following which I commented on:

  • Endpoint Explorer (.http) and Swagger UI testing instructions
  • .NET 9 update to content instruction plus .NET 9 targeted app sample.

If you want to do those, and want to do them in a new PR, let me know and I will publish this PR. If you want to make those changes in this PR, that is fine too, either way.

@wadepickett wadepickett self-assigned this Apr 7, 2025
@timdeschryver
Copy link
Contributor Author

@wadepickett if you're OK with it I prefer to merge this in.
I should have the time to update the code to .NET 9 later this week.
I'll try to include the testing docs next week, I expect this to be the biggest PR.

I will create the issues for this later today so we don't forget about it.
Thanks for taking the time to review and elaborate.

@wadepickett wadepickett merged commit 9006424 into dotnet:main Apr 8, 2025
3 checks passed
@timdeschryver timdeschryver deleted the first-mongo-app branch April 8, 2025 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web API with MongoDB: Add link to Source Code web API with MongoDB: Fix Try it out steps web API with MongoDB: Unnecessary Command

2 participants