When I pass a username as a value to the ASP.NET Core MVC action method, its parameter gets null as an argument. what can I do to avoid this?
I know it's a common question but I am stuck.
Angular code:
callExternalProject(username : string): Observable<any> {
return this.http.post<any>(`${environment.CMRDashboardURL}/Account/LoginUser`,username) .pipe(
catchError(error => {
return throwError(() => new Error(error))
})
);
}
ASP.NET Core MVC code:
[HttpPost]
public IActionResult LoginUser(string Username)
{
string viewName = "Login";
if (string.IsNullOrEmpty(Username))
{
ViewBag.Emptybox = "User name can not be empty.";
return View(viewName, Username);
}
}
Screenshots:
Frontend screenshot
Backend screenshot
Login the third application from Angular frontend by passing the username from the Angular side