我有一个角度2方法:
version: '3.3'
services:
fancyservice:
restart: always
image: fancyservice
aat-runner:
environment:
- FancyServiceUrl=http://fancyservice/
- COMPOSE_CONVERT_WINDOWS_PATHS=1
volumes:
- .:/output:rw
restart: always
image: aat-runner
volumes:
- aat-output:c:\aat-output\
volumes:
aat-output:
一个ASP.Net Core方法,它接收HttpContext
login(usernameparam: string, passwordparam: string): Observable<boolean> {
let headers = new Headers({
'Content-Type': 'application/x-www-form-urlencoded', 'Accept-Charset': 'utf-16', 'Access-Control': 'Allow - Origin'
});
let options = new RequestOptions({ headers: headers });
return this.http.post('http://localhost:64116/token',
{ username : usernameparam, password: passwordparam },
options)
.map((response: Response) => {
// login successful if there's a jwt token in the response
debugger;
let token = response.json() && response.json().token;
if (token) {
this.token = token;
localStorage.setItem('currentUser', JSON.stringify({ username: usernameparam, token: token }));
return true;
} else {
return false;
}
});
}
然而,当我收到HttpContext时,用户名和密码都是空的。在查看来自浏览器的请求时,它明确指出,Form-Data包含这两个。我错过了什么?