【发布时间】:2018-08-10 10:12:49
【问题描述】:
当我使用 get 进行 api 调用时,当我转换为发布它在参数中给我空值时,它工作得很好。我必须使用 [FromBody] 然后只调用 api 但仍然给我参数值 null。我也处理过 CORS。
const httpOptions = {
headers: new HttpHeaders({
'Content':"application/json",
'Content-Type': 'application/json;charset=utf-8',
//'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Authorization': 'Basic ' + btoa(Username + ":" + Password),
}),
};
checkLogin(form){
var obj = { Business_Email: form["Business_Email"], Business_Password: form["Business_Password"] };
return this.http.post(this.API_URL+"/Login/LoginValid", JSON.stringify(obj),httpOptions)
}
我在 Asp .net C# 中有 Web Api
[HttpPost]
[ActionName("LoginValid")]
[Route("api/Login/LoginValid")]
public ReturnObject LoginValid([FromBody]string businessMaster)
{
//Code
}
【问题讨论】: