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/blazor/call-web-api.md
+36-11Lines changed: 36 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Learn how to call a web API from Blazor apps.
5
5
monikerRange: '>= aspnetcore-3.1'
6
6
ms.author: riande
7
7
ms.custom: mvc
8
-
ms.date: 03/08/2024
8
+
ms.date: 09/25/2024
9
9
uid: blazor/call-web-api
10
10
---
11
11
# Call a web API from ASP.NET Core Blazor
@@ -242,6 +242,37 @@ You can address this by flowing prerendered state using the Persistent Component
242
242
243
243
:::moniker-end
244
244
245
+
:::moniker range=">= aspnetcore-9.0"
246
+
247
+
## Client-side request streaming
248
+
249
+
For Chromium-based browsers (for example, Google Chrome and Microsoft Edge) using the HTTP/2 protocol, HTTPS, and [CORS](xref:security/cors), client-side Blazor uses [Streams API](https://developer.mozilla.org/docs/Web/API/Streams_API) to permit [request streaming](https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests).
250
+
251
+
To enable request streaming, set <xref:Microsoft.AspNetCore.Components.WebAssembly.Http.WebAssemblyHttpRequestMessageExtensions.SetBrowserRequestStreamingEnabled%2A> to `true` on the <xref:System.Net.Http.HttpRequestMessage>.
252
+
253
+
In the following file upload example:
254
+
255
+
*`content` is the file's <xref:System.Net.Http.HttpContent>.
* Require HTTPS protocol and don't work on HTTP/1.x.
270
+
* Include a body but not a `Content-Length` header. [CORS](xref:security/cors) is required, and CORS preflight request is always issued.
271
+
272
+
For more information on file uploads with an <xref:Microsoft.AspNetCore.Components.Forms.InputFile> component, see <xref:blazor/file-uploads#file-size-read-and-upload-limits> and the example at [Upload files to a server with client-side rendering (CSR)](xref:blazor/file-uploads#upload-files-to-a-server-with-client-side-rendering-csr).
273
+
274
+
:::moniker-end
275
+
245
276
## Add the `HttpClient` service
246
277
247
278
*The guidance in this section applies to client-side scenarios.*
@@ -257,10 +288,7 @@ In the `Program` file, add an <xref:System.Net.Http.HttpClient> service if it is
The preceding example sets the base address with `builder.HostEnvironment.BaseAddress` (<xref:Microsoft.AspNetCore.Components.WebAssembly.Hosting.IWebAssemblyHostEnvironment.BaseAddress%2A?displayProperty=nameWithType>), which gets the base address for the app and is typically derived from the `<base>` tag's `href` value in the host page.
@@ -274,10 +302,7 @@ If you're calling an external web API (not in the same URL space as the client a
0 commit comments