Passing Data from one action method to another action method

Manideepgoud
Posted by Manideepgoud under ASP.NET MVC category on | Points: 40 | Views : 353
Passing Data from one action method to another action method
public ActionResult Index()
{
TempData.Add["MyTempData", "This is from calling method"]
return RedirectToAction("TempDataMethod")
}

public ActionResult TempDataMethod()
{
return Content(TempData["MyTempData"]).ToString();
}



Retaining TempData Value using Keep and Peek Methods

string data = TempData["MyTempData"].ToString();


Keep Method
string data=TempData.Keep("MyTempData").Tostring();

Peek Method

string data=TempData.Peek("MyTempData").ToString();

Comments or Responses

Login to post response