2021-06-11 15:44:31 +10:00
|
|
|
|
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
|
|
|
|
|
{
|
2021-06-15 22:21:54 +10:00
|
|
|
|
public ActionResult Method1()
|
2021-06-11 15:44:31 +10:00
|
|
|
|
{
|
2021-06-15 22:21:54 +10:00
|
|
|
|
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();
|
2021-06-11 15:44:31 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|