Temp data is dictionary derived from temp datadictionary class and stored in session.
ViewData is a dictionary of objects that is derived from
ViewDataDictionary class and accessible using strings as keys. The basic
difference view data is available only current request where as temp
data available in two successive requests, after that they are
destroyed. In other words when you redirect, “Tempdata” helps to
maintain data between those redirects
If we want “TempData” to be read and also available in the subsequent
request then after reading we need to call “Keep” method as shown in the
code below.
TempData.Keep("MyData");
No comments:
Post a Comment