Skip to content

Conversation

@dariatiurina
Copy link
Contributor

TempData support for Blazor

Description

This PR adds support for TempData in Blazor, enabling temporary data storage for Server-Side rendering (SSR) that persists across requests, such as for passing messages or state between pages. It includes the TempData API, its implementation, integration into the dependency injection system, and initial end-to-end tests and UI components demonstrating its use.

Changes:

  • Added a new ITempData interface defining methods for storing, retrieving, peeking, and retaining temporary data, as well as indexer access.
  • Implemented the TempData class, providing the logic for managing temporary data, including methods for getting, peeking, keeping, saving, and loading data.
  • Integrated TempData into the service collection, making it available as a cascading value in Blazor endpoint scenarios. It loads TempData from the HTTP context and ensures it is saved back to cookies on response.
  • Added TempDataService for serializing/deserializing TempData to/from cookies, handling supported types and data conversion.
  • Added end-to-end tests verifying that TempData can persist values across navigation.

Fixes #49683

@github-actions github-actions bot added the area-blazor Includes: Blazor, Razor Components label Dec 12, 2025
@dariatiurina dariatiurina self-assigned this Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blazor TempData

1 participant