public PartialViewResult Divide(int numerator, int denominator) { CalculatorServiceWCFClient client = new CalculatorServiceWCFClient(); int result = client.Divide(numerator, denominator); return(PartialView("Divide", result)); }
private void btnDivide_Click(object sender, EventArgs e) { try { CalculatorServiceWCFClient client = new CalculatorServiceWCFClient("WSHttpBinding_ICalculatorServiceWCF"); // wsHttpBinding - after exception occurs service will be lost. we need to create need instance of service after that lblResultDivide.Text = client.Divide(Convert.ToInt32(tbNumerator.Text), Convert.ToInt32(tbDenominator.Text)).ToString(); } catch (FaultException ex) //catch (FaultException<DivideByZeroFault> ex) // Strongly typed exception { lblResultDivide.Text = $"{ex.Code} - {ex.Message}"; //lblResultDivide.Text = $"{ex.Detail.Error} - {ex.Detail.Details}"; } }