using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using FirstMVCDemo.Models; using FirstMVCDemo.ViewModels; namespace FirstMVCDemo.Controllers { public class EmployeeController : Controller { public ActionResult Method1() { TempData["Name"] = "Pranaya"; TempData["Age"] = 30; return View(); } public ActionResult Method2() { string Name; int Age; if (TempData.ContainsKey("Name")) Name = TempData["Name"].ToString(); if (TempData.ContainsKey("Age")) Age = int.Parse(TempData["Age"].ToString()); TempData.Keep(); // do somethign with userName or userAge Ahere return View(); } public ActionResult Method3() { string Name; int Age; if (TempData.ContainsKey("Name")) Name = TempData["Name"].ToString(); if (TempData.ContainsKey("Age")) Age = int.Parse(TempData["Age"].ToString()); return View(); } } }