【发布时间】:2017-09-29 12:51:08
【问题描述】:
从我发送数据的页面:
register() {
this.loading = true;
this.Register = { firstName: 'aa', lastName: 'aa', email: 'aa', password: 'aa', cpassword: 'aa', gender: "male", dob: '2017-05-02' };
this.userService.create(this.Register)
.subscribe(
data => {
alert("aa");
},
error => {
// this.alertService.error(error);
this.loading = false;
});
}
我从 Angular 2 服务代码中发布了我的数据如下:
create(UserRegister: UserRegister) {
return this.http.post('http://localhost:53625/api/UserLoginAPI/InsertUser', UserRegister, this.jwt()).map((response: Response) => response.json());
}
private jwt() {
let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' });
return new RequestOptions({ headers: headers });
}
为此我在api中编写代码如下:
[HttpPost]
public IHttpActionResult InsertUser(UserRegisterModel UserRegister)
{
int returnval = 0;
returnval = objUserLoginBAL.InsertUser(objUserRegisterModel);
return Json(returnval);
}
我在 api 端接到电话,但我的对象没有得到任何价值。如图所示:
【问题讨论】:
标签: post asp.net-web-api angular2-forms angular2-services