How can I return custom status (404 or any another) and custom exception(or message) using AppService from backend. Example: UI call back-end get method and backend did't find needed data or some bussines validation accure, so I want return the status 404, with my exception message, but I don't want that ui treat this like usual exception and show UI standart exception modal, better for me that I could provide custom behavior for user?
4 Answer(s)
-
0
https://github.com/aspnetboilerplate/aspnetboilerplate/blob/95b19dbce4a9785fdac1d6f5ca74fa16dd690eeb/src/Abp.AspNetCore/AspNetCore/Mvc/Results/AbpResultFilter.cs#L22
https://github.com/aspnetboilerplate/aspnetboilerplate/blob/354d66d76f63391ee3fd524d7cd35a1701fd3b71/src/Abp.AspNetCore/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs#L69
You can override the AbpResultFilter and customize the status code.
Use UserFriendlyException custom message .
-
0
but this both methods is inside the nuget package, so how I should deal with them?
-
1
Override (and replace), not modify.
Implement
IResultFilter
and replaceAbpResultFilter
: https://stackoverflow.com/questions/47888802/disable-wrapping-of-controller-resultsOverride and replace
AbpExceptionFilter
: https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3280 -
0
Thanks, I would try.