@TempData[“MyData”];
TempData.Keep(“MyData”);
TempData.Keep(“MyData”);
The same behavior can be achieved using Peek function in ASP.NET MVC. This function enables ASP.NET MVC to maintain TempData for the subsequent request.
string str = TempData.Peek("MyData").ToString();