I hava 2 controllers: ControllerA and ControllerB, and set value for session in controllerA, but can't get value in ControllerB, code like:
public class ControllerA : Controller
{
public ActionResult Index()
{
Session["a"] = "test";
}
}
public class ControllerB : Controller
{
public ActionResult Index()
{
ViewBag.Test = Session["a"].ToString();
}
}
I tried use cookie to instead of session, but has same problem. I don't know if I should use session in C# MVC, please let me know if something is better then session. Thank you.