Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing middleware in the tutorial generated code #34317

Open
dotocan1 opened this issue Dec 9, 2024 · 1 comment
Open

Missing middleware in the tutorial generated code #34317

dotocan1 opened this issue Dec 9, 2024 · 1 comment
Assignees
Labels
aspnet-core/svc Source - Docs.ms Docs Customer feedback via GitHub Issue tutorials/subsvc

Comments

@dotocan1
Copy link

dotocan1 commented Dec 9, 2024

Description

Hello, the problem I found is that you have to manually add the:

app.AddControllers();
app.MapControllers();

middleware in the Program.cs file.
It does not get generated automatically when using the console command:
dotnet new webapi -o BookStoreApi

Without it, the routes don't get called.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mongo-app?view=aspnetcore-8.0&tabs=visual-studio-code#test-the-web-api

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/tutorials/first-mongo-app.md

Document ID

83a5cb3b-23bc-4f0c-cd1c-1d1ffeb1131a

Article author

@wadepickett

Related Issues

@timdeschryver
Copy link
Contributor

If it's OK, I'd like to work on this issue.
Let me know if I can help in any way.

Because minimal is the default now, I think this can be fixed by updating the dotnet new command to use controllers:

- dotnet new webapi -o BookStoreApi
+ dotnet new webapi --use-controllers -o BookStoreApi

Side note: I noticed the codesample used in the article references the 6.x code, while there's a newer 8.x example. I can also update this and create a 9.x example and update the instructions to use .NET 9. I also mention this because the article uses 8.x.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aspnet-core/svc Source - Docs.ms Docs Customer feedback via GitHub Issue tutorials/subsvc
Projects
None yet
Development

No branches or pull requests

3 participants