In ASP.NET MVC, a field which is declare outside a method, the field is initialize every-time.
There I am giving a demo example.
public class TestController : Controller
{
private List<object> ListItems;
// GET: /Test/Index
public ActionResult Index(int Id)
{
ModelSource _model = new ModelSource(Id);
ListItems = _model.GetItems();//coming info from Model
return View();
}
// GET: /Test/Demo
public ActionResult Demo()
{
int x = ListItems.Count;
//Do Something More
return View(x);
}
}
Is It possible for ListItems
will be initialize for once for every client as Id
parameter will be different on client's request.