0

I fill the model and the TempData

private const string MyTempModel = "MyTempModel";

        [HttpGet]
        public ActionResult Abm()
        {
            var modelo = DependencyContainer.Instance.Resolve<MyModel>();
            modelo.Name = "Maxi" ;
            modelo.LastName = "Dam";
            TempData[MyController.MyTempModel] = modelo;

            return View(modelo);
        }

And here I want to get the values

 [HttpGet]
            public ActionResult Save()
            {
                var model = TempData[MyController.MyTempModel] as MyModel;
                return View(model);
            }

What I'm doing wrong? I lose all the values...

Thanks

MCSI
  • 2,818
  • 26
  • 35

2 Answers2

3

TempData will be around for the life the current request and the next request only...

Alex
  • 34,899
  • 5
  • 77
  • 90
1

You will want to use session if you want the data to persist over several requests.

Check this thread for more info

Community
  • 1
  • 1
Willem D'Haeseleer
  • 19,661
  • 9
  • 66
  • 99