3

A little background. A developer I used to work with insisted on disabling Tempdata and using Session Flash for passing data in the return view.

Question is, is there any advantage to doing it this way? using a flash message is great for returning data to the user but I've had headaches with passing data from one post to the next with tempdata disabled.

Is there any problem with using flash and tempdata together or is this a major coding faux paus?

asked Apr 16, 2012 at 16:17

1 Answer 1

5

Temporarily putting things in the session is going to lead to strange behavior when a user opens up 2 or more windows. TempData is best for persisting data briefly.

Also, sessions can be cleared a variety of ways. TempData will rewrite a bit of data on the page to be posted back and will last as long as the window isn't closed.

There's also the problem of session scalability. Most applications won't run into a problem here but larger applications can be affected.

If you're still not convinced here's a coding guidelines document from Microsoft encouraging the use of tempdata over the session

Glorfindel
3,1676 gold badges28 silver badges34 bronze badges
answered Apr 16, 2012 at 17:20
1
  • Thanks. I was never convinced that his use of session flash was the correct way to go and your answer and the link confirm this. Commented Apr 16, 2012 at 19:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.