Update http-context.md (#22698)
* Update http-context.md * Update aspnetcore/fundamentals/http-context.md * Update http-context.md * Update http-context.md * Update aspnetcore/fundamentals/http-context.md * Update aspnetcore/fundamentals/http-context.md Co-authored-by: Kirk Larkin <serpent5@pm.me> Co-authored-by: Kirk Larkin <serpent5@pm.me>pull/22891/head
parent
d77506c7d3
commit
6d9b1468ce
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
title: Access HttpContext in ASP.NET Core
|
||||
author: coderandhiker
|
||||
description: Learn how to access HttpContext in ASP.NET Core.
|
||||
description: HttpContext in ASP.NET Core. HttpContext is not thread-safe and can throw NullReferenceException.
|
||||
monikerRange: '>= aspnetcore-2.1'
|
||||
ms.author: riande
|
||||
ms.custom: mvc
|
||||
|
@ -138,6 +138,7 @@ To safely perform background work with `HttpContext` data:
|
|||
|
||||
* Copy the required data during request processing.
|
||||
* Pass the copied data to a background task.
|
||||
* Do ***not*** reference `HttpContext` data in parallel tasks. Extract the data needed from the context before starting the parallel tasks.
|
||||
|
||||
To avoid unsafe code, never pass the `HttpContext` into a method that performs background work. Pass the required data instead. In the following example, `SendEmailCore` is called to start sending an email. The `correlationId` is passed to `SendEmailCore`, not the `HttpContext`. Code execution doesn't wait for `SendEmailCore` to complete:
|
||||
|
||||
|
|
Loading…
Reference in New Issue