private void UpdateJson(InfographicSettingsModel model)
        {
            using (var fs = System.IO.File.Open(Server.MapPath("signups.txt"), FileMode.Truncate))
            using (var sw = new StreamWriter(fs))
            using (JsonWriter jw = new JsonTextWriter(sw))
            {
                jw.Formatting = Formatting.None;

                var serializer = new JsonSerializer();
                serializer.Serialize(jw, model);
            }
        }
 public ActionResult Index()
 {
     var model = new InfographicSettingsModel();
     using (var fs = System.IO.File.Open(Server.MapPath("signups.txt"), FileMode.Open))
     {
         using (var sw = new StreamReader(fs))
         {
             using (var jw = new JsonTextReader(sw))
             {
                 var serializer = new JsonSerializer();
                 model = serializer.Deserialize<InfographicSettingsModel>(jw);
             }
         }
     }
     return View(model ?? new InfographicSettingsModel());
 }
        public ActionResult Index(InfographicSettingsModel model)
        {
            if (!ModelState.IsValid) return View(model);

            try
            {
                UpdateJson(model);
                model.Message = "Changes saved.";
            }
            catch (IOException ex)
            {
                //file is being used by another process, retry
                UpdateJson(model);
            }

            return View(model);
        }