Skip to content

Commit 3235a1a

Browse files
authored
Merge branch 'main' into guardrex-patch-4
2 parents dfe523f + 261ab6a commit 3235a1a

File tree

6 files changed

+12
-14
lines changed

6 files changed

+12
-14
lines changed

aspnetcore/blazor/components/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,6 +1854,10 @@ For more information, see the following resources:
18541854
* <xref:mvc/views/tag-helpers/builtin-th/component-tag-helper>
18551855
* <xref:blazor/components/integration>
18561856

1857+
## `IHttpContextAccessor`/`HttpContext`
1858+
1859+
[!INCLUDE[](~/blazor/security/includes/httpcontext.md)]
1860+
18571861
<!--Reference links in article-->
18581862
[1]: <xref:mvc/views/razor#code>
18591863
[2]: <xref:mvc/views/razor#using>

aspnetcore/blazor/fundamentals/signalr.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ Use a <xref:Microsoft.AspNetCore.Components.Server.Circuits.CircuitHandler> to c
14561456

14571457
## Start the SignalR circuit at a different URL
14581458

1459-
Prevent automatically starting the app by adding `autostart="false"` to the Blazor `<script>` tag ([location of the Blazor start script](xref:blazor/project-structure#location-of-the-blazor-script)). Establish the circuit URL manually using `Blazor.start`. The following example uses the path `/signalr`:
1459+
Prevent automatically starting the app by adding `autostart="false"` to the Blazor `<script>` tag ([location of the Blazor start script](xref:blazor/project-structure#location-of-the-blazor-script)). Manually establish the circuit URL using `Blazor.start`. The following example uses the path `/signalr`:
14601460

14611461
```diff
14621462
- <script src="_framework/blazor.web.js"></script>
@@ -1470,15 +1470,15 @@ Prevent automatically starting the app by adding `autostart="false"` to the Blaz
14701470
+ </script>
14711471
```
14721472

1473-
Add the following <xref:Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub%2A> call with the `/signalr` path to the middleware processing pipeline in the server app's `Program` file:
1473+
Add the following <xref:Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub%2A> call with the hub path to the middleware processing pipeline in the server app's `Program` file:
14741474

14751475
```csharp
14761476
app.MapBlazorHub("/signalr");
14771477
```
14781478

14791479
:::moniker-end
14801480

1481-
## `IHttpContextAccessor`/`HttpContext` in Razor components
1481+
## `IHttpContextAccessor`/`HttpContext`
14821482

14831483
[!INCLUDE[](~/blazor/security/includes/httpcontext.md)]
14841484

aspnetcore/blazor/security/blazor-web-app-with-oidc.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ The `BlazorWebAppOidc` project is the server-side project of the Blazor Web App.
4444

4545
The `BlazorWebAppOidc.http` file can be used for testing the weather data request. Note that the `BlazorWebAppOidc` project must be running to test the endpoint, and the endpoint is hardcoded into the file. For more information, see <xref:test/http-files>.
4646

47-
> [!NOTE]
48-
> The server project uses <xref:Microsoft.AspNetCore.Http.IHttpContextAccessor>/<xref:Microsoft.AspNetCore.Http.HttpContext>, but never for interactively-rendered components. For more information, see <xref:blazor/security/interactive-server-side-rendering#ihttpcontextaccessorhttpcontext-in-razor-components>.
49-
5047
### Configuration
5148

5249
This section explains how to configure the sample app.
@@ -306,9 +303,6 @@ The `BlazorWebAppOidc` project is the server-side project of the Blazor Web App.
306303

307304
The `BlazorWebAppOidc.http` file can be used for testing the weather data request. Note that the `BlazorWebAppOidc` project must be running to test the endpoint, and the endpoint is hardcoded into the file. For more information, see <xref:test/http-files>.
308305

309-
> [!NOTE]
310-
> The server project uses <xref:Microsoft.AspNetCore.Http.IHttpContextAccessor>/<xref:Microsoft.AspNetCore.Http.HttpContext>, but never for interactively-rendered components. For more information, see <xref:blazor/security/interactive-server-side-rendering#ihttpcontextaccessorhttpcontext-in-razor-components>.
311-
312306
### Configuration
313307

314308
This section explains how to configure the sample app.
@@ -503,7 +497,7 @@ Inspect the sample app for the following features:
503497
* Automatic non-interactive token refresh with the help of a custom cookie refresher (`CookieOidcRefresher.cs`).
504498
* The server project calls <xref:Microsoft.Extensions.DependencyInjection.WebAssemblyRazorComponentsBuilderExtensions.AddAuthenticationStateSerialization%2A> to add a server-side authentication state provider that uses <xref:Microsoft.AspNetCore.Components.PersistentComponentState> to flow the authentication state to the client. The client calls <xref:Microsoft.Extensions.DependencyInjection.WebAssemblyAuthenticationServiceCollectionExtensions.AddAuthenticationStateDeserialization%2A> to deserialize and use the authentication state passed by the server. The authentication state is fixed for the lifetime of the WebAssembly application.
505499
* Requests to the Blazor Web App are proxied to the backend web API project (`MinimalApiJwt`). `MapForwarder` in the `Program` file adds direct forwarding of HTTP requests that match the specified pattern to a specific destination using default configuration for the outgoing request, customized transforms, and default HTTP client:
506-
* When rendering the `Weather` component on the server, the component uses the `ServerWeatherForecaster` to proxy the request for weather data with the user's access token.
500+
* When rendering the `Weather` component on the server, the component uses the `ServerWeatherForecaster` class to proxy the request for weather data with the user's access token. <xref:Microsoft.AspNetCore.Http.IHttpContextAccessor.HttpContext?displayProperty=nameWithType> determines if an <xref:Microsoft.AspNetCore.Http.HttpContext> is available for use by the `GetWeatherForecastAsync` method. For more information, see <xref:blazor/components/index#ihttpcontextaccessorhttpcontext>.
507501
* When the component is rendered on the client, the component uses the `ClientWeatherForecaster` service implementation, which uses a preconfigured <xref:System.Net.Http.HttpClient> (in the client project's `Program` file) to make a web API call to the server project. A Minimal API endpoint (`/weather-forecast`) defined in the server project's `Program` file transforms the request with the user's access token to obtain the weather data.
508502

509503
:::moniker-end
@@ -513,7 +507,7 @@ Inspect the sample app for the following features:
513507
* Automatic non-interactive token refresh with the help of a custom cookie refresher (`CookieOidcRefresher.cs`).
514508
* The `PersistingAuthenticationStateProvider` class (`PersistingAuthenticationStateProvider.cs`) is a server-side <xref:Microsoft.AspNetCore.Components.Authorization.AuthenticationStateProvider> that uses <xref:Microsoft.AspNetCore.Components.PersistentComponentState> to flow the authentication state to the client, which is then fixed for the lifetime of the WebAssembly application.
515509
* Requests to the Blazor Web App are proxied to the backend web API project (`MinimalApiJwt`). `MapForwarder` in the `Program` file adds direct forwarding of HTTP requests that match the specified pattern to a specific destination using default configuration for the outgoing request, customized transforms, and default HTTP client:
516-
* When rendering the `Weather` component on the server, the component uses the `ServerWeatherForecaster` to proxy the request for weather data with the user's access token.
510+
* When rendering the `Weather` component on the server, the component uses the `ServerWeatherForecaster` class to proxy the request for weather data with the user's access token. <xref:Microsoft.AspNetCore.Http.IHttpContextAccessor.HttpContext?displayProperty=nameWithType> determines if an <xref:Microsoft.AspNetCore.Http.HttpContext> is available for use by the `GetWeatherForecastAsync` method. For more information, see <xref:blazor/components/index#ihttpcontextaccessorhttpcontext>.
517511
* When the component is rendered on the client, the component uses the `ClientWeatherForecaster` service implementation, which uses a preconfigured <xref:System.Net.Http.HttpClient> (in the client project's `Program` file) to make a web API call to the server project. A Minimal API endpoint (`/weather-forecast`) defined in the server project's `Program` file transforms the request with the user's access token to obtain the weather data.
518512

519513
:::moniker-end

aspnetcore/blazor/security/includes/httpcontext.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
:::moniker range=">= aspnetcore-8.0"
22

3-
<xref:Microsoft.AspNetCore.Http.IHttpContextAccessor> must be avoided with interactive rendering because there isn't a valid `HttpContext` available.
3+
<xref:Microsoft.AspNetCore.Http.IHttpContextAccessor> generally should be avoided with interactive rendering because a valid <xref:Microsoft.AspNetCore.Http.HttpContext> isn't always available.
44

55
<xref:Microsoft.AspNetCore.Http.IHttpContextAccessor> can be used for components that are statically rendered on the server. **However, we recommend avoiding it if possible.**
66

aspnetcore/blazor/security/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ The built-in or custom <xref:Microsoft.AspNetCore.Components.Authorization.Authe
108108

109109
For more information on server-side authentication, see <xref:blazor/security/index>.
110110

111-
### `IHttpContextAccessor`/`HttpContext` in Razor components
111+
### `IHttpContextAccessor`/`HttpContext`
112112

113113
[!INCLUDE[](~/blazor/security/includes/httpcontext.md)]
114114

aspnetcore/blazor/security/interactive-server-side-rendering.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ In general, we recommend that you avoid rendering components that contain sensit
6060

6161
[!INCLUDE[](~/blazor/security/includes/shared-state.md)]
6262

63-
## `IHttpContextAccessor`/`HttpContext` in Razor components
63+
## `IHttpContextAccessor`/`HttpContext`
6464

6565
[!INCLUDE[](~/blazor/security/includes/httpcontext.md)]
6666

0 commit comments

Comments
 (0)