MVC TempData Nighmare

S

shapper

Hello,

I created a view, Feedback, that displays a message to the user.

So every time I need to display a message to the user I use the
following:

TempData.Add("Message", message);
return RedirectToAction("Feedback", "Home", TempData);

Message is an object with 3 properties: Title, Description and
IconUrl.

I have been experience 3 problems:

1. When I redirect to feedback its url becomes:


http://localhost:2920/Home/Feedback...2+KeyCollection[System.String,System.Object]&
Values=System.Collections.Generic.Dictionary%602%2BValueCollection
[System.String%2CSystem.Object]

2. When I refresh Feedback view the message disappears;

In part I understand why but how do I preserve it ... and should I
use ViewData instead of TempData for this?

How can I solve these problems?

Could someone, please, help me out?

Thanks,

Miguel
 
G

Gregory Beamer

Try these two

1. Make the object serializable - this means the object can actually be
broken down into XML
2. Make sure session state is turned on - it is on by default, but you may
have turned off (deleted section of web.config, etc.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top