public async Task <ActionResult> Create(UserDetails Model) { var results = new ServerResponse(); try { results = await userService.InsertUserDetailsAsync(Model); } catch (FaultException ex) { var arr = ex.Message.Split('\n').ToArray(); if (arr[0].Contains("validation errors")) { arr = arr.Skip(2).ToArray(); foreach (var error in arr) { if (!string.IsNullOrWhiteSpace(error.Trim())) { var key = error.Split(' ')[1]; ModelState.AddModelError(key, error.TrimEnd()); } } TempData["UserErrors"] = ModelState; return(new HttpStatusCodeResult(422, "Validation Errors.")); } else { return(Json(results, JsonRequestBehavior.AllowGet)); } } return(Json(results, JsonRequestBehavior.AllowGet)); }