Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Add a cookie based ITempDataProvider #5212

Closed
DamianEdwards opened this issue Aug 31, 2016 · 9 comments
Closed

Add a cookie based ITempDataProvider #5212

DamianEdwards opened this issue Aug 31, 2016 · 9 comments

Comments

@DamianEdwards
Copy link
Member

DamianEdwards commented Aug 31, 2016

Using TempData today requires the manual configuration of session state. It would be great to have a provider available that uses cookies (protected with Data Protection) to round-trip the temp data information so that session state isn't required.

While we likely can't change this to be the default (:cry:) it would be awesome to have it be available.

Temp data is a great solution for showing form success messages after a Post-Redirect-Get cycle and the need to use session state for that today is overkill.

@rynowak @sebastienros @danroth27

@brockallen
Copy link

Here's one for MVC 5: https://github.com/brockallen/CookieTempData

@javiercn
Copy link
Member

javiercn commented Sep 1, 2016

+1! (No reactions on mobile)

@rynowak
Copy link
Member

rynowak commented Sep 1, 2016

/cc @blowdart any concerns with this?

@blowdart
Copy link
Member

blowdart commented Sep 1, 2016

Ewww. Session in cookies? Remember there's a max size on cookies from a site.

As long as it's ran through data protection, which will increase the size, and the cookies are limited to the app path, and they're HTTP Only and, if you're on HTTPS they're marked secure, then fine.

@luisgoncalves
Copy link

Already had one implemented as a package... Anyway, maybe you could make the cookie name configurable.

@John0King
Copy link

@DamianEdwards Why use Cookie or Session ? Create a Dictionary when Contorller be invoked, and share it beteen Controller, View, PartialView and ViewComponent ( same reference ) , Is this will do current TempData's Job?

@ivaylokenov
Copy link
Contributor

@John0King No. The TempData persists the stored data until the next request.

@John0King
Copy link

@ivaylokenov I still don't understand ? Does the second requset will get the TempData ?

@ivaylokenov
Copy link
Contributor

ivaylokenov commented Oct 27, 2016

@John0King Yes, if you put data in the TempData, it will be there for the current and for the next request by default. The data needs to be persisted between the requests. Cookies or session are logical choices for the persistence.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants