Keep and Peek in Temp Data
It's very important question for ASP.NET MVC Developer. This question always ask in interview, difference between Keep and Peek in Temp Data.
Let us know about Temp Data.
Temp Data
Temp Data is used for transfer data information between controller to view & controller to controller navigation.
Temp Data is used for transfer data information between controller to view & controller to controller navigation.
Temp Data will be persisted depend on 4 condition in New or second request in same session.
1. Not Read : Temp Data will be persisted for second request if you don't read in view.
2. Read : Temp Data will not persisted for another request if you read in View or Controller.
3. Read and Keep : Temp Data will be persisted for second request if read and call Keep for Temp Data.
TempData.Keep has persisted two types of overload methods:
a) .keep(): means all data will not be deleted on completion of this request.
b) .keep(string value) : means specific item will be persisted for next request with specifying value.
TempData.Keep has persisted two types of overload methods:
a) .keep(): means all data will not be deleted on completion of this request.
b) .keep(string value) : means specific item will be persisted for next request with specifying value.
var KeyData = TempData["KeyData"]; //marked TempData for deletion TempData.Keep("KeyData"); //unmarked TempData
4. Peek and Read : Temp Data will also be persisted for Second Request if read and Call Peek for Temp Data.
Comments
Post a Comment