Reputation: 1476
I am setting the value of TempData in one ActionResult of different controller and trying to get their Keys of just counts in another controller's ActionResult
public ActionResult DealProducts(FormCollection form)
{
TempData["check"] = "DealUpdated";
}
in another controller
public ActionResult CustomizedBudget()
{
var temp = TempData["doc"];
var temp = TempData["doc"].Key;//like this
if (temp.Count > 0) // or trying to get like this, but not
}
Upvotes: 0
Views: 2159
Reputation: 407
To Assign
public ActionResult DealProducts(FormCollection form)
{
TempData["check"] = "DealUpdated";
}
In CSHTML
@{
TempData.Keep("check");
}
in another controller
public ActionResult CustomizedBudget()
{
var count = TempData.Keys.Count;
var DealUpdatedValue = TempData["check"];
}
Upvotes: 2
Reputation: 616
you need to change in below Action
public ActionResult CustomizedBudget()
{ var temp = TempData["check"]; }
Upvotes: 1
Reputation: 785
well since you have
public ActionResult DealProducts(FormCollection form)
{
TempData["check"] = "DealUpdated";
}
shouldn't you have
public ActionResult CustomizedBudget()
{
var temp = TempData["check"];
var temp = TempData["check"].Key;//like this
if (temp.Count > 0) // or trying to get like this, but not
}
?
Upvotes: 1