Skip to content

Blazor TempData #49683

Closed

Description

@danroth27

MVC & Razor Pages have a TempData feature that you can use to store some data that is intended to be read in a future request. We should consider adding something similar for Blazor server-side rendering.

For example, the default Identity UI makes use of TempData in variety of scenarios. We need some way to replicate this functionality.

Activity

  1. ghost added
    area-blazor
    on Jul 27, 2023
  2. added
    enhancement
    on Jul 31, 2023
  3. added this to the .NET 9 Planning milestone on Jul 31, 2023
  4. added
    Priority:2
    on Jan 16, 2024
  5. mq-gh-dev commented on Jul 13, 2025

    @mq-gh-dev

    I would like to request this too, especially since Blazor 8's push for static SSR pages and the fact that these are used extensively in Identity.

    The TempData would provide a lot more convenience for static SSR pages. Take the IdentityRedirectionManager.cs for example in the official Blazor unfied web app tempate with Identity - it uses 5-second flash cookies to set/read status messages which is unreliable. It would have been much better if TempData was used.

    In the meantime, I was trying to find a workaround, and found that manually registering

    builder.Services.AddMvcCore().AddViews();
    

    would make ITempDataDictionaryFactory available for use in Blazor services, with a caveat: the automatic ITempDataDirectory.Save() calls do not work, so we have to manually call it after setting/reading data, otherwise they won't be persisted/cleared properly.

    It would have been very nice if the Blazor team could bring TempData properly into Blazor.

  6. mq-gh-dev commented on Jul 14, 2025

    @mq-gh-dev

    I made an example of the TempData usage in Blazor SSR:

    https://github.com/mq-gh-dev/blazor-ssr-tempdata

  7. Johnhersh commented on Oct 6, 2025

    @Johnhersh

    I would also love this

  8. added
    on-roadmap
    on Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Pillar: Complete Blazor WebPriority:2area-blazorenhancementon-roadmap

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions