In my controller say ControllerFirst I am setting a ViewBag property by the below line.
ViewBag.PreviousPage="ThisIsComingFromControllerFirst";
return RedirectToAction("ControllerSecond", "Home");
Now from here:
public ActionResult ControllerSecond()
{
return View();
}
I am trying to use Viewbag in the ControllerSecond by the following
View: ControllerSecond.cshtml
@if(ViewBag.PreviouPage == "SomeValue")
{
//do this
}
But ViewBag.PreviousPage value is null.
Please let me know why its null, what could I do to get the value in my view from the ControllerFirst.
I have done this one using Session, but We don't want to sessions..
Any other options?