public ActionResult Index(Person person) { if (ModelState.IsValid) { string fn = Server.MapPath("~/Save.txt"); StreamWriter f = System.IO.File.CreateText(fn); f.WriteLine("Firstmame = " + person.FirstName + ", Lastname = " + person.LastName); f.Close(); } return View(person); }
// GET: Home public ActionResult Index() { string fn = Server.MapPath("~/Save.txt"); StreamReader f = System.IO.File.OpenText(fn); var line = f.ReadLine(); Person p = new Person(); var parts = line.Split(','); p.FirstName = parts[0].Split('=')[1]; p.LastName = parts[1].Split('=')[1]; f.Close(); return View(p); }