ABP ver 9.3.5 with micro-services architecture, the UserFriendlyException not shown on the razor page client when backend API throw a UserFriendlyException, below is the code section:
A BusinessException threw but it cannot shown on the client side in a application service like below:
`
public virtual async Task
if (!result)
{
throw new InvalidVerificationCodeException();
}
var identityUser = await _phoneNumberLoginNewUserCreator.CreateAsync(input.PhoneNumber, input.UserName, input.Password, input.EmailAddress);
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(identityUser);
}
`
the InvalidVerificationCodeException is a BusinessException
I added an UserFriendlyException in the Controller like below:
`
[HttpPost]
[Route("register/by-phone-number")]
public virtual async Task
return result;
}
catch (BusinessException ex)
{
throw new UserFriendlyException(ex.Code);
}
}
`
it got below logs in the backend:
`
2025-10-08 17:38:45.887 +08:00 [WRN] ---------- RemoteServiceErrorInfo ----------
{ "code": null, "message": "EasyAbp.Abp.PhoneNumberLogin:InvalidVerificationCode", "details": null, "data": {}, "validationErrors": null }
2025-10-08 17:38:45.887 +08:00 [WRN] EasyAbp.Abp.PhoneNumberLogin:InvalidVerificationCode Volo.Abp.UserFriendlyException: EasyAbp.Abp.PhoneNumberLogin:InvalidVerificationCode at EasyAbp.Abp.PhoneNumberLogin.Web.Controllers.PhoneNumberLogin.Account.LoginController.RegisterByPhoneNumberAsync(RegisterWithPhoneNumberInput input) at lambda_method3691(Closure, Object) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.
then the client get a 403 forbidden HTTP Status code with the errors like below, it doesn't use UI throw a message:
{ "error": { "code": null, "message": "EasyAbp.Abp.PhoneNumberLogin:InvalidVerificationCode", "details": null, "data": {}, "validationErrors": null } }
5 Answer(s)
-
0
hi
The UserFriendlyException not shown on the razor page client
What is your razor page code?
Thanks
-
0
[maliming] said: hi
The UserFriendlyException not shown on the razor page client
What is your razor page code?
Thanks
Not any specified code, just a form submit, send a phonenumber and a verification code to API side.
-
0
Use abp.ajax will show the messages.
https://abp.io/docs/latest/framework/ui/mvc-razor-pages/javascript-api/ajax
-
0
Thanks your helping, maliming
-
0
Great