You can assign the finalData
to a Session
or TempData
variable.
TempData["FinalData "] = finalData;
return RedirectToAction("ActionName");
From this answer: "TempData
Allows you to store data that will survive for a redirect. Internally it uses the Session, it's just that after the redirect is made the data is automatically evicted"
Then in your GET
Action Method,
Public ActionResult AcionName()
{
var finalData = TempData["FinalData"] as IGrouping<string, ModelName>;
return View("ActionName", finalData);
}
The problem is, if you were to refresh after the redirect, then finalData
would be null. So, in that case you use Session["FinalData"]
or get the data from the Database in your Get method again. You can go through the answer I have linked for disadvantages of using TempData
.