Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Change reponse codes returned #6677


User avatar
0
joe704la created

How can we change the response code returned from a UserFriendlyException? Because it is throwing an exception it returns a 500 response code which our web application blocks what is returned from that so that no sensitive server errors are returned.


4 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, can you share the project framework and version?

    if you are changing for some of the UserFriendlyException only. You can pass the status code in the UserFriendlyException constructor

  • User Avatar
    0
    joe704la created

    Oh sorry yes, It is Angular, ASP.NET Core project on version ASPNet Zero 6.6.1. I am currently in the process of upgrading to 6.8

    I did not know you could do that. Is there documentation on that?

  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, there is documentation on exception handling which probably suits your use case.

    See https://aspnetboilerplate.com/Pages/Documents/AspNet-Core#exception-filter

    You can also refer to the apporach mentioned in this thread for some code examples.

    https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3280

  • User Avatar
    0
    joe704la created

    Thank you. This helped a lot