Update app-state.md (#28355)

pull/28356/head
Rick Anderson 2023-02-10 16:29:52 -10:00 committed by GitHub
parent 1e1a90b7d8
commit 05352f915b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -173,6 +173,10 @@ The following example shows how to set and get a serializable object with the `S
[!code-csharp[](app-state/6.0samples/SessionSample/Pages/Index6.cshtml.cs)]
> [!WARNING]
> Storing live object in session should be used with caution as there are many problems than can occur with searilized objects. For more information [see this GitHub issue](https://github.com/dotnet/aspnetcore/issues/18159)
## TempData
ASP.NET Core exposes the Razor Pages [TempData](xref:Microsoft.AspNetCore.Mvc.RazorPages.PageModel.TempData) or Controller <xref:Microsoft.AspNetCore.Mvc.Controller.TempData>. This property stores data until it's read in another request. The [Keep(String)](xref:Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary.Keep*) and [Peek(string)](xref:Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary.Peek*) methods can be used to examine the data without deletion at the end of the request. [Keep](xref:Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary.Keep*) marks all items in the dictionary for retention. `TempData` is: