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

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top