public ActionResult Index(string startDate, string endDate, string locationAndEpc, string user, string itemsPerPage) { int format = 0; bool inputError = false; DateTime start = new DateTime(); DateTime end = new DateTime(); VehicleServiceClient vehicleService = new VehicleServiceClient(); string[] locationEpcArray = locationAndEpc.Split('*'); string location = locationEpcArray[0]; String locationEPC = locationEpcArray[1]; bool authenticated = vehicleService.AuthenticateUser(user); //ViewBags ViewBag.start = startDate; ViewBag.end = endDate; ViewBag.locc = locationAndEpc; ViewBag.epc = locationEPC; ViewBag.usr = user; vehiclePassageList.Clear(); //Checks if itemsPerPage, startDate or endDate are in the wrong format if (Int32.TryParse(itemsPerPage, out format) == false || DateTime.TryParse(startDate, out start) == false || DateTime.TryParse(endDate, out end) == false) { //if any of them are, sets format to -1 which will cause a responseCode 2, resulting in an error inputError = true; format = 1; } else { format = Convert.ToInt32(itemsPerPage); } // fullXmlAnswer = vehicleService.XmlAnswer(start, end, locationEPC, location, user, authenticated); fullXmlAnswer = vehicleService.XmlAnswer(start, end, locationEPC, location, user, authenticated, inputError); foreach (XElement vehiclePassage in fullXmlAnswer.Descendants("FordonPassage")) { vehiclePassageList.Add(new VehiclePassage(vehiclePassage)); } return(RedirectToAction("SearchResults", new { size = format })); }