Good I am new in ASP.net in which I am focusing in the MVC. Here I show the following code.
public class ClientesController : Controller
{
public List<Cliente> clientes = new List<Cliente>();
// GET: Cliente
public ActionResult Index()
{
return View();
}
public ActionResult Login()
{
return View();
}
public ActionResult Nuevos_Clientes()
{
return View();
}
public ActionResult VerDatos()
{
return View();
}
// Post de Venta
[HttpPost]
public ActionResult Nuevos_Clientes(String nombre, String apellidos, String dni, int edad)
{
clientes.Add(new Cliente(nombre, apellidos, dni, edad));
return View("VerDatos", clientes);
}
What I'm trying to do is create a list of client-type objects and using a form that is reflected in the "New_Clients" action method, I pass the following data by parameter (name, surname, IDN and age). So my idea as shown by the method of action is that each time the registration button of the form is saved in the list. And in fact that is done, the problem is when I reload the page (Vista) New_Customers according to the debugging of the code it re-executes the line where the list is created (new List), losing the object that it had previously, so that if I registered a client that record will no longer be displayed. So how do I correct that problem? I hope you can help me, thanks