I found that I shouldn't use Session
a lot in ASP MVC here, here and in other places.
So, I want to know if it's better to use TempData
like I did below or not.
public ActionResult Action1()
{
if (SomeCondition)
{
/*
I want to show alert to user based on this value that should appear in Action2 view
So, is it better to:
1. Session["user"] = "something";
2. TempData["user"] = "something";
*/
return RedirectToAction("Action2");
}
return View();
}
public ActionResult Action2()
{
/*
1. I can read Session["user"] in the view
2. TempData["user"] = TempData["user"].ToString();
Now I can read TempData in the view
*/
return View();
}