I am trying to call to a Web API from MVC POST action method and receive a result but not sure how, for example:
[HttpPost]
public ActionResult Submit(Model m)
{
// Get the posted form values and add to list using model binding
IList<string> MyList = new List<string> { m.Value1,
m.Value2, m.Value3, m.Value4};
return Redirect???? // Redirct to web APi POST
// Assume this would be a GET?
return Redirect("http://localhost:41174/api/values")
}
I wish to send the above MyList to the Web Api to be processed, then it will send a result (int) back to the original controller:
// POST api/values
public int Post([FromBody]List<string> value)
{
// Process MyList
// Return int back to original MVC conroller
}
Have no idea how to proceed, any help appreciated.