我创建了项目(FrontEnd的Angular / Typescript,Backend的C#Controllers)。
虽然我可以通过以下方式运行GET方法:
http.get(originUrl + '/api/Poker/GetPokerValues').subscribe(result => {
this.pokerValues = result.json() as PokerValue[];
});
执行后端方法:
[HttpGet("[action]")]
public IEnumerable<PokerValue> GetPokerValues()
{ //this code does execute
return List;
}
我仍然无法通过(Typescript)代码运行POST方法:
var url = this._originUrl + '/api/Poker/SetPokerValue';
this._http.post(url, dataToPass, {
headers: headers
}).map(response => response.json());
在控制器上:
[HttpPost("[action]")]
public ActionResult SetPokerValue(string someVar)
{//this code does not execute
return Json("Success");
}
你知道我做错了什么让它起作用吗?
这是我的代码: https://github.com/kamilhawdziejuk/Scrum/blob/master/Angular/Controllers/PokerController.cs