public IActionResult Add(KVmodel kvmodel) { if (kvmodel.Text != null) { string[] values = kvmodel.Text.Split('='); if (values.Length == 2) { keyValueList.AddPair(values[0], values[1]); } else { string text = "Bad format: item must consist of a single key value pair separated by '='"; return(RedirectToAction("Error", new ErrorViewModel { Text = text })); } } var model = new KVmodel(keyValueList.DisplayList); return(RedirectToAction("Index", model)); }