【发布时间】:2015-02-07 13:21:57
【问题描述】:
我正在尝试从 MVC POST 操作方法调用 Web API 并接收结果但不确定如何,例如:
[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")
}
我希望将上面的 MyList 发送到 Web Api 进行处理,然后它将结果(int)发送回原始控制器:
// POST api/values
public int Post([FromBody]List<string> value)
{
// Process MyList
// Return int back to original MVC conroller
}
不知道如何继续,感谢任何帮助。
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-4 asp.net-web-api