Condition 1 (Not read): If you set a “
TempData” inside your action and if you do not read it in your view, then “TempData” will be persisted for the next request.
Condition 2 (Normal Read): If you read the “
TempData” normally like the below code, it will not persist for the next requeststringstr = TempData[“MyData”];
Even if you are displaying, it’s a normal read like the code below:
@TempData[“MyData”];
Condition 3 (Read and Keep): If you read the “
TempData” and call the “Keep” method, it will be persisted.@TempData[“MyData”];
TempData.Keep(“MyData”);
Condition 4 ( Peek and Read): If you read “
TempData” by using the “Peek” method, it will persist for the next request.stringstr = TempData.Peek("Td").ToString();
No comments:
Post a Comment