return this.http.post<User>(`${environment.apiUrl}/api/users/LoginUser/`, { UserName, Password })
我尝试将参数传递给链接,但是当请求进入服务器时,参数值保持为空。
login(userName:string, password:string) {
const headers = new HttpHeaders().set('Content-Type', 'application/json');
var body = {
"UserName": userName,
"Password": password
}
return this.http.post<User>(`${environment.apiUrl}/api/users/LoginUser/`, body
,{
withCredentials: null,
headers: headers,
})
}
.net
[HttpPost]
[Route("LoginUser")]
//[EnableCors("AllowOrigin")]
public ResponseObject<User> LoginUser(User user)
{
UsersBLL bll = new UsersBLL();
User user = bll.LoginUser(user.UserName, user.Password);
string Token = Common.JwtHelper.CreateToken(user.Id.ToString(), user.Email);
user.Token = Token;
bll.UpdateUser(user);
return SvcResponse.SuccessReponse<User>(user);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句