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;

 

You Might Also Like

Leave a Reply