public ActionResult RecordCount() { dynamic count = 0; try { if (ModelState.IsValid) { AuctionServiceClient service = new AuctionServiceClient(); count = service.RecordCount(); } } catch (Exception e) { ModelState.AddModelError("error", "Something went wrong"); count = null; throw e; } return(Json(new { count }, JsonRequestBehavior.AllowGet)); }