Angular registration sends a POST request to an ASP.NET Core endpoint but the backend isn’t receiving all fields, triggering 400 errors.
import { Component } from '@angular/core';
import { UserService } from '../services/user.service';
@Component({
selector: 'app-signup',
templateUrl: './signup.component.html',
styleUrls: ['./signup.component.scss']
})
export class SignupComponent {
userForm = { email: '', pwd: '', displayName: '' };
constructor(private userService: UserService) {}
sendForm(): void {
this.userService.createUser(this.userForm).subscribe();
}
}
i think the issue might be with model binding in your core api. sometimes even a slight mismatch in property names or case sensitivity causes the params to be dropped. double-check your c# model to make sure everything lines up.
hey, maybe issue lies in missing json headers. have u checked if angular sends the right content-type? i had a similar prob and switching headers fixed it. what about u, have u tried debugging the network requests to reveal any anomalies?
I encountered a similar issue when implementing user registration in Angular. In my case, the error stemmed from incomplete configuration of the API endpoint. I resolved it by explicitly decorating the parameter in the POST method with the [FromBody] attribute, which ensured that all JSON properties were bound correctly. Also, I verified that the JSON payload structure matched the model exactly, including property names and cases. These small adjustments significantly improved consistency between the front-end data and backend model binding, eliminating the 400 errors.
hey, i also ran into similar issues before. it might be a binding mess with nested data. have u tried checking the actual json payload in the network tab? maybe the api config needs a tweak too. what do u think might be off with it?