Skip to content

Commit c6ad091

Browse files
committed
HttpContext/IHttpContextAccessor article
1 parent 44e4427 commit c6ad091

File tree

6 files changed

+20
-13
lines changed

6 files changed

+20
-13
lines changed

aspnetcore/blazor/security/includes/httpcontext.md renamed to aspnetcore/blazor/components/http-context.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
---
2+
title: `IHttpContextAccessor`/`HttpContext` in ASP.NET Core Blazor apps
3+
author: guardrex
4+
description: Learn about IHttpContextAccessor and HttpContext in Blazor.
5+
monikerRange: '>= aspnetcore-8.0'
6+
ms.author: riande
7+
ms.custom: mvc
8+
ms.date: 01/29/2025
9+
uid: blazor/components/httpcontext
10+
---
11+
# `IHttpContextAccessor`/`HttpContext` in ASP.NET Core Blazor apps
12+
13+
[!INCLUDE[](~/includes/not-latest-version-without-not-supported-content.md)]
14+
115
:::moniker range=">= aspnetcore-8.0"
216

317
<xref:Microsoft.AspNetCore.Http.IHttpContextAccessor> generally should be avoided with interactive rendering because a valid <xref:Microsoft.AspNetCore.Http.HttpContext> isn't always available.

aspnetcore/blazor/components/index.md

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

1868-
## `IHttpContextAccessor`/`HttpContext`
1869-
1870-
[!INCLUDE[](~/blazor/security/includes/httpcontext.md)]
1871-
18721868
<!--Reference links in article-->
18731869
[1]: <xref:mvc/views/razor#code>
18741870
[2]: <xref:mvc/views/razor#using>

aspnetcore/blazor/fundamentals/signalr.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,10 +1507,6 @@ app.MapBlazorHub();
15071507
+ app.MapBlazorHub("/signalr");
15081508
```
15091509

1510-
## `IHttpContextAccessor`/`HttpContext`
1511-
1512-
[!INCLUDE[](~/blazor/security/includes/httpcontext.md)]
1513-
15141510
## Additional server-side resources
15151511

15161512
* [Server-side host and deployment guidance: SignalR configuration](xref:blazor/host-and-deploy/server#signalr-configuration)
@@ -1521,6 +1517,7 @@ app.MapBlazorHub();
15211517
* <xref:blazor/security/index>
15221518
* <xref:blazor/security/interactive-server-side-rendering>
15231519
* <xref:blazor/security/additional-scenarios>
1520+
* <xref:blazor/components/httpcontext>
15241521
* [Server-side reconnection events and component lifecycle events](xref:blazor/components/lifecycle#blazor-server-reconnection-events)
15251522
* [What is Azure SignalR Service?](/azure/azure-signalr/signalr-overview)
15261523
* [Performance guide for Azure SignalR Service](/azure/azure-signalr/signalr-concept-performance)

aspnetcore/blazor/security/index.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ 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`
112-
113-
[!INCLUDE[](~/blazor/security/includes/httpcontext.md)]
114-
115111
### Shared state
116112

117113
[!INCLUDE[](~/blazor/security/includes/shared-state.md)]
@@ -1417,6 +1413,7 @@ PII refers any information relating to an identified or identifiable natural per
14171413
* [Microsoft identity platform access tokens](/entra/identity-platform/access-tokens)
14181414
* <xref:security/index>
14191415
* <xref:security/authentication/windowsauth>
1416+
* <xref:blazor/components/httpcontext>
14201417
* [Build a custom version of the Authentication.MSAL JavaScript library](xref:blazor/security/webassembly/additional-scenarios#build-a-custom-version-of-the-authenticationmsal-javascript-library)
14211418
* [Awesome Blazor: Authentication](https://github.com/AdrienTorris/awesome-blazor#authentication) community sample links
14221419
* <xref:blazor/hybrid/security/index>
@@ -1438,6 +1435,7 @@ PII refers any information relating to an identified or identifiable natural per
14381435
* [Microsoft identity platform ID tokens](/entra/identity-platform/id-tokens)
14391436
* [Microsoft identity platform access tokens](/entra/identity-platform/access-tokens)
14401437
* <xref:security/index>
1438+
* <xref:blazor/components/httpcontext>
14411439
* <xref:security/authentication/windowsauth>
14421440
* [Build a custom version of the Authentication.MSAL JavaScript library](xref:blazor/security/webassembly/additional-scenarios#build-a-custom-version-of-the-authenticationmsal-javascript-library)
14431441
* [Awesome Blazor: Authentication](https://github.com/AdrienTorris/awesome-blazor#authentication) community sample links

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

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

6363
## `IHttpContextAccessor`/`HttpContext`
6464

65-
[!INCLUDE[](~/blazor/security/includes/httpcontext.md)]
65+
For more information, see <xref:blazor/components/httpcontext>.
6666

6767
## Resource exhaustion
6868

aspnetcore/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ items:
484484
uid: blazor/components/render-modes
485485
- name: Prerender components
486486
uid: blazor/components/prerender
487+
- name: IHttpContextAccessor and HttpContext
488+
uid: blazor/components/httpcontext
487489
- name: Generic type support
488490
uid: blazor/components/generic-type-support
489491
- name: Synchronization context

0 commit comments

Comments
 (0)