예제 #1
0
 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);
 }
예제 #2
0
        // 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);
        }