I'm working in Angular 5 and Asp.Net Web API
In angular I have service and component, so component receive parameter from view like this:
forgotPass() {
this.loading = true;
debugger;
this._authService.forgotPassword(this.model.email).subscribe(
data => {
this.toastr.success("Sended success")
this.loading = false;
LoginCustom.displaySignInForm();
this.model = {};
},
error => {
this.showAlert('alertForgotPass');
this._alertService.error(error);
this.loading = false;
});
}
and service execute controller like this:
forgotPassword(email: string) {
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.post(this.rootUrl + '/ChangePasswordToken', JSON.stringify({ email: email }), options)
.map((response: Response) => {
});
}
As you can see I send parameter email
to WebApi, problem is controller receive it as null, but when I debbugging JS it send email success:
Controller:
[Route("ChangePasswordToken")]
public async Task<IActionResult> GeneratePasswordChangeToken(string email)
{//code there}
Why I always get null in controller if angular sended it correctly? Regards