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/web-api/action-return-types.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,12 @@
1
1
---
2
2
title: Controller action return types in ASP.NET Core web API
3
+
ai-usage: ai-assisted
3
4
author: tdykstra
4
5
description: ActionResult vs IActionResult
5
6
monikerRange: '>= aspnetcore-3.1'
6
7
ms.author: tdykstra
7
8
ms.custom: mvc
8
-
ms.date: 6/20/2023
9
+
ms.date: 02/26/2026
9
10
uid: web-api/action-return-types
10
11
---
11
12
# Controller action return types in ASP.NET Core web API
@@ -37,7 +38,7 @@ When multiple return types are possible, it's common to mix an <xref:Microsoft.A
37
38
38
39
### Return IEnumerable\<T> or IAsyncEnumerable\<T>
39
40
40
-
See [Return `IEnumerable<T>` or `IAsyncEnumerable<T>`](/aspnet/core/fundamentals/best-practices#return-ienumerablet-or-iasyncenumerablet) for performance considerations.
41
+
See [Return `IEnumerable<T>` or `IAsyncEnumerable<T>`](xref:fundamentals/best-practices#return-ienumerablet-or-iasyncenumerablet) for performance considerations.
41
42
42
43
ASP.NET Core buffers the result of actions that return <xref:System.Collections.Generic.IEnumerable%601> before writing them to the response. Consider declaring the action signature's return type as <xref:System.Collections.Generic.IAsyncEnumerable%601> to guarantee asynchronous iteration. Ultimately, the iteration mode is based on the underlying concrete type being returned and the selected formatter affects how the result is processed:
43
44
@@ -97,7 +98,7 @@ If the [`[ApiController]`](xref:Microsoft.AspNetCore.Mvc.ApiControllerAttribute)
97
98
98
99
## ActionResult vs IActionResult
99
100
100
-
The following section compares `ActionResult` to `IActionResult`
101
+
The following section compares `ActionResult` to `IActionResult`.
101
102
102
103
### ActionResult\<T> type
103
104
@@ -144,12 +145,12 @@ In the preceding action:
144
145
145
146
## HttpResults type
146
147
147
-
In addition to the MVC-specific built-in result types (<xref:Microsoft.AspNetCore.Mvc.IActionResult> and [ActionResult\<T>](xref:Microsoft.AspNetCore.Mvc.ActionResult%601)), ASP.NET Core includes the [HttpResults](xref:Microsoft.AspNetCore.Http.HttpResults) types that can be used in both [Minimal APIs](/aspnet/core/fundamentals/minimal-apis) and Web API.
148
+
In addition to the MVC-specific built-in result types (<xref:Microsoft.AspNetCore.Mvc.IActionResult> and [ActionResult\<T>](xref:Microsoft.AspNetCore.Mvc.ActionResult%601)), ASP.NET Core includes the [HttpResults](xref:Microsoft.AspNetCore.Http.HttpResults) types that can be used in both [Minimal APIs](xref:fundamentals/minimal-apis) and Web API.
148
149
149
150
Different than the MVC-specific result types, the `HttpResults`:
150
151
151
152
* Are a results implementation that is processed by a call to [IResult.ExecuteAsync](xref:Microsoft.AspNetCore.Http.IResult.ExecuteAsync%2A).
152
-
* Does ***not*** leverage the configured [Formatters](/aspnet/core/web-api/advanced/formatting#format-specific-action-results). Not leveraging the configured formatters means:
153
+
* Does ***not*** leverage the configured [Formatters](xref:web-api/advanced/formatting#format-specific-action-results). Not leveraging the configured formatters means:
153
154
154
155
* Some features like `Content negotiation` aren't available.
155
156
* The produced `Content-Type` is decided by the `HttpResults` implementation.
@@ -160,7 +161,7 @@ The `HttpResults` can be useful when sharing code between Minimal APIs and Web A
160
161
161
162
The <xref:Microsoft.AspNetCore.Http.HttpResults> namespace contains classes that implement the <xref:Microsoft.AspNetCore.Http.IResult> interface. The `IResult` interface defines a contract that represents the result of an HTTP endpoint. The static [Results](<xref:Microsoft.AspNetCore.Http.Results>) class is used to create varying `IResult` objects that represent different types of responses.
162
163
163
-
The [Built-in results](/aspnet/core/fundamentals/minimal-apis#built-in-results) table shows the common result helpers.
164
+
The [Built-in results](xref:fundamentals/minimal-apis#built-in-results) table shows the common result helpers.
Copy file name to clipboardExpand all lines: aspnetcore/web-api/action-return-types/includes/action-return-types7.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ When multiple return types are possible, it's common to mix an <xref:Microsoft.A
24
24
25
25
### Return IEnumerable\<T> or IAsyncEnumerable\<T>
26
26
27
-
See [Return `IEnumerable<T>` or `IAsyncEnumerable<T>`](/aspnet/core/fundamentals/best-practices#return-ienumerablet-or-iasyncenumerablet) for performance considerations.
27
+
See [Return `IEnumerable<T>` or `IAsyncEnumerable<T>`](xref:fundamentals/best-practices#return-ienumerablet-or-iasyncenumerablet) for performance considerations.
28
28
29
29
ASP.NET Core buffers the result of actions that return <xref:System.Collections.Generic.IEnumerable%601> before writing them to the response. Consider declaring the action signature's return type as <xref:System.Collections.Generic.IAsyncEnumerable%601> to guarantee asynchronous iteration. Ultimately, the iteration mode is based on the underlying concrete type being returned and the selected formatter affects how the result is processed:
30
30
@@ -84,7 +84,7 @@ If the [`[ApiController]`](xref:Microsoft.AspNetCore.Mvc.ApiControllerAttribute)
84
84
85
85
## ActionResult vs IActionResult
86
86
87
-
The following section compares `ActionResult` to `IActionResult`
87
+
The following section compares `ActionResult` to `IActionResult`.
88
88
89
89
### ActionResult\<T> type
90
90
@@ -131,12 +131,12 @@ In the preceding action:
131
131
132
132
## HttpResults type
133
133
134
-
In addition to the MVC-specific built-in result types (<xref:Microsoft.AspNetCore.Mvc.IActionResult> and [ActionResult\<T>](xref:Microsoft.AspNetCore.Mvc.ActionResult%601)), ASP.NET Core includes the [HttpResults](xref:Microsoft.AspNetCore.Http.HttpResults) types that can be used in both [Minimal APIs](/aspnet/core/fundamentals/minimal-apis) and Web API.
134
+
In addition to the MVC-specific built-in result types (<xref:Microsoft.AspNetCore.Mvc.IActionResult> and [ActionResult\<T>](xref:Microsoft.AspNetCore.Mvc.ActionResult%601)), ASP.NET Core includes the [HttpResults](xref:Microsoft.AspNetCore.Http.HttpResults) types that can be used in both [Minimal APIs](xref:fundamentals/minimal-apis) and Web API.
135
135
136
136
Different than the MVC-specific result types, the `HttpResults`:
137
137
138
138
* Are a results implementation that is processed by a call to [IResult.ExecuteAsync](xref:Microsoft.AspNetCore.Http.IResult.ExecuteAsync%2A).
139
-
* Does ***not*** leverage the configured [Formatters](/aspnet/core/web-api/advanced/formatting#format-specific-action-results). Not leveraging the configured formatters means:
139
+
* Does ***not*** leverage the configured [Formatters](xref:web-api/advanced/formatting#format-specific-action-results). Not leveraging the configured formatters means:
140
140
141
141
* Some features like `Content negotiation` aren't available.
142
142
* The produced `Content-Type` is decided by the `HttpResults` implementation.
@@ -275,7 +275,7 @@ If the [`[ApiController]`](xref:Microsoft.AspNetCore.Mvc.ApiControllerAttribute)
275
275
276
276
## ActionResult vs IActionResult
277
277
278
-
The following section compares `ActionResult` to `IActionResult`
278
+
The following section compares `ActionResult` to `IActionResult`.
0 commit comments