dotnet / dotnet/AspNetCore.Docs

Wrong example code at demoing the ability of returning different IResult implementations

Open
#29,494 3 comments 0 reactions 0 assignees View on GitHub
doc-enhancement RR Source - Docs.ms
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 3h
Merged PRs (30d)
97

Description

In the docs [here](https://github.com/dotnet/AspNetCore.Docs/blob/ce2f890e9c9af43bf542c0f6037edae9a0be406c/aspnetcore/fundamentals/minimal-apis/responses.md?plain=1#L92) you explain the difference of the methods avail in Results vs TypedResults classes:
**_The following method compiles because both Results.Ok and Results.NotFound are declared as returning IResult, even though the actual concrete types of the objects returned are different_**
However, next to that you show an example of the `TypedResults` usage which returns explicitly typed results and not `IResult`, and the reason is compiles is cause of the generic `Results` used as the return type of the method. This example does not belong here, and is used later in the article, sounds like it was copied here by mistake.

---
#### Document Details

⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*

* ID: f0e5da68-cd54-ce74-1ff3-ebd7d9fd09a4
* Version Independent ID: f0e5da68-cd54-ce74-1ff3-ebd7d9fd09a4
* Content: [Create responses in Minimal API applications](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/responses?view=aspnetcore-7.0)
* Content Source: [aspnetcore/fundamentals/minimal-apis/responses.md](https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/minimal-apis/responses.md)
* Product: **aspnet-core**
* Technology: **aspnetcore-fundamentals**
* GitHub Login: @brunolins16
* Microsoft Alias: **brolivei**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.