我的错误消息和代码如下。调用了service.ts方法,但是使用了http调用 无法达到控制器类。我也启用了cors,但结果是 还是一样。
Service.ts
saveEmployee(employee : User) {
return this._http.post(this.myAppUrl + 'api/RoadSign/RegisterUser', employee).map((response: Response) => response.json()).catch(this.errorHandler)
}
Controller.cs
[Route("api/[controller]")]
[EnableCors("AllowSpecificOrigin")]
public class RoadSignController : Controller
{
[HttpPost]
[Route("RegisterUser")]
public int Create([FromBody] User employee)
{
_repoWrapper.userRepo.Create(employee);
return 1;
}