Skip to content

Commit 4dcfc53

Browse files
committed
Add example for Problem result in Minimal APIs
1 parent fd0f269 commit 4dcfc53

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

aspnetcore/fundamentals/minimal-apis/9.0-samples/Snippets/Program.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,14 @@ public static void Main(string[] args)
4646
// <snippet_10>
4747
app.MapGet("/download", () => Results.File("myfile.text"));
4848
// </snippet_10>
49-
49+
// <snippet_12>
50+
app.MapGet("/problem", () =>
51+
{
52+
var extensions = new List<KeyValuePair<string, object?>> { new("test", "value") };
53+
return TypedResults.Problem("This is an error with extensions",
54+
extensions: extensions);
55+
});
56+
// </snippet_12>
5057
app.Run();
5158
}
5259
// <snippet_11>

aspnetcore/fundamentals/minimal-apis/responses.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ The following sections demonstrate the usage of the common result helpers.
146146

147147
The preceding example returns a 500 status code.
148148

149+
#### Problem and ValidationProblem
150+
151+
:::code language="csharp" source="~/fundamentals/minimal-apis/9.0-samples/Snippets/Program.cs" id="snippet_12":::
152+
149153
#### Text
150154

151155
:::code language="csharp" source="~/fundamentals/minimal-apis/9.0-samples/Snippets/Program.cs" id="snippet_08":::

0 commit comments

Comments
 (0)