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
+49-1Lines changed: 49 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ The [`System.Net.Http.Json`](https://www.nuget.org/packages/System.Net.Http.Json
22
22
23
23
## Sample apps
24
24
25
-
See the sample apps in the [`dotnet/blazor-samples`](https://github.com/dotnet/blazor-samples/)GitHub repository.
25
+
For working examples, see the following sample apps in the [Blazor samples GitHub repository (`dotnet/blazor-samples`)](https://github.com/dotnet/blazor-samples/)([how to download](xref:blazor/fundamentals/index#sample-apps)).
26
26
27
27
### `BlazorWebAppCallWebApi`
28
28
@@ -80,6 +80,8 @@ public class ServerMovieService(MovieContext db) : IMovieService
80
80
}
81
81
```
82
82
83
+
For more information on how to secure movie data in this scenario, see the weather data example described by [Secure data in Blazor Web Apps with Interactive Auto rendering](xref:blazor/security/index#secure-data-in-blazor-web-apps-with-interactive-auto-rendering).
84
+
83
85
### `BlazorWebAppCallWebApi_Weather`
84
86
85
87
A weather data sample app that uses streaming rendering for weather data.
@@ -91,6 +93,40 @@ Calls a todo list web API from a Blazor WebAssembly app:
91
93
*`Backend`: A web API app for maintaining a todo list, based on [Minimal APIs](xref:fundamentals/minimal-apis).
92
94
*`BlazorTodo`: A Blazor WebAssembly app that calls the web API with a preconfigured <xref:System.Net.Http.HttpClient> for todo list CRUD operations.
93
95
96
+
### `BlazorWebAssemblyStandaloneWithIdentity`
97
+
98
+
A standalone Blazor WebAssembly app secured with ASP.NET Core Identity:
99
+
100
+
*`Backend`: A backend web API app that maintains a user identity store for ASP.NET Core Identity.
101
+
*`BlazorWasmAuth`: A standalone Blazor WebAssembly frontend app with user authentication.
102
+
103
+
The solution demonstrates calling a secure web API for the following:
104
+
105
+
* Obtaining an authenticated user's roles.
106
+
* Data processing for all authenticated users.
107
+
* Data processing for authorized users (the user must be in the `Manager` role) via an [authorization policy](xref:security/authorization/policies).
108
+
109
+
### `BlazorWebAppOidc`
110
+
111
+
A Blazor Web App with global Auto interactivity that uses OIDC authentication with Microsoft Entra without using Entra-specific packages. The solution includes a demonstration of obtaining weather data securely via a web API when a component that adopts Interactive Auto rendering is rendered on the client.
112
+
113
+
### `BlazorWebAppOidcBff`
114
+
115
+
A Blazor Web App with global Auto interactivity that uses:
116
+
117
+
* OIDC authentication with Microsoft Entra without using Entra-specific packages.
118
+
* The [Backend for Frontend (BFF) pattern](/azure/architecture/patterns/backends-for-frontends), which is a pattern of app development that creates backend services for frontend apps or interfaces.
119
+
120
+
The solution includes a demonstration of obtaining weather data securely via a web API when a component that adopts Interactive Auto rendering is rendered on the client.
121
+
122
+
:::moniker-end
123
+
124
+
:::moniker range=">= aspnetcore-9.0"
125
+
126
+
### `BlazorWebAppEntra`
127
+
128
+
A Blazor Web App with global Auto interactivity that uses [Microsoft identity platform](/entra/identity-platform/)/[Microsoft Identity Web packages](/entra/msal/dotnet/microsoft-identity-web/) for [Microsoft Entra ID](https://www.microsoft.com/security/business/microsoft-entra). The solution includes a demonstration of obtaining weather data securely via a web API when a component that adopts Interactive Auto rendering is rendered on the client.
129
+
94
130
:::moniker-end
95
131
96
132
## Client-side scenarios for calling external web APIs
@@ -1050,9 +1086,21 @@ Various network tools are publicly available for testing web API backend apps di
1050
1086
1051
1087
### General
1052
1088
1089
+
:::moniker range=">= aspnetcore-8.0"
1090
+
1091
+
*[Cross-Origin Resource Sharing (CORS) at W3C](https://www.w3.org/TR/cors/)
1092
+
*<xref:security/cors>: Although the content applies to ASP.NET Core apps, not Razor components, the article covers general CORS concepts.
1093
+
*[Secure data in Blazor Web Apps with Interactive Auto rendering](xref:blazor/security/index#secure-data-in-blazor-web-apps-with-interactive-auto-rendering)
1094
+
1095
+
:::moniker-end
1096
+
1097
+
:::moniker range="< aspnetcore-8.0"
1098
+
1053
1099
*[Cross-Origin Resource Sharing (CORS) at W3C](https://www.w3.org/TR/cors/)
1054
1100
*<xref:security/cors>: Although the content applies to ASP.NET Core apps, not Razor components, the article covers general CORS concepts.
1055
1101
1102
+
:::moniker-end
1103
+
1056
1104
### Mitigation of overposting attacks
1057
1105
1058
1106
Web APIs can be vulnerable to an *overposting* attack, also known as a *mass assignment* attack. An overposting attack occurs when a malicious user issues an HTML form POST to the server that processes data for properties that aren't part of the rendered form and that the developer doesn't wish to allow users to modify. The term "overposting" literally means that the malicious user has *over*-POSTed with the form.
0 commit comments