ASP.NET Calculator

2

I'm doing a small exercise of operations consuming a Web Service, but I can not find a way to show the result in the view, I'm not using Model.

controller

{
    return View();
}

[HttpPost]
public ActionResult Index(int primero, int segundo)
{
    // Creación de un objeto de referencia del servicio web  
    ServiceReference1.CalculatorSoapClient multi = new ServiceReference1.CalculatorSoapClient();

    // llama y almacena el resultado del servicio web en la variable  
    var multiplicac = multi.Multiply(primero, segundo);
    return View();
}
    
asked by Richard 11.01.2018 в 15:15
source

1 answer

4

you can pass the value to the view in the following way:

public ActionResult NombreView()
{
  ViewData["multiplicac"] = multi.Multiply(primero, segundo);
    return View();
}

and then in the view you can use it doing:

   @Html.Encode(ViewData["multiplicac"].ToString())
    
answered by 11.01.2018 / 15:52
source