public ActionResult GetInvoice() { dynamic invNo = 0; try { if (ModelState.IsValid) { SaleServiceClient service = new SaleServiceClient(); invNo = service.GetInvoice(); //return Json(invNo, JsonRequestBehavior.AllowGet); } } catch (Exception ex) { ModelState.AddModelError("error", "Something Went Wrong"); invNo = null; throw ex; } return(Json(invNo, JsonRequestBehavior.AllowGet)); }