Temp Data uses in MVC

Tempdata is a dictionary object which derives fromĀ TempDataDictionary,Tempdata is very uses full for below uses

1)Passing data from Action to Action in same controller

2)passing data from one controller to another controller

3)From View to Action

4)From Action To view

5)From View To view

Tempdata has short live, after getting value from tempdata , the live of tempdata will destroy.

For keeping tempdata value , have to use tempdata.keep().

It requires to type cast and check for null also to avoid error.

plod=TempData[“TmpCart”] as CartModel;


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>