T
T
Tsiren Naimanov2016-04-25 02:35:47
ASP.NET
Tsiren Naimanov, 2016-04-25 02:35:47

What is the best way to implement a response from the controller on error?

Good morning!
Can anyone suggest which way to choose better?)
What is the best way to implement the response from the controller on error?
1. return a 404 header or any other for a specific situation, without content
2. return a static / customized error page
I hope for answers confirmed by practice or literature ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-04-25
@ImmortalCAT

1) the status of the code depends on the error (404 is a bad response when you need to return 403 for example)
2) it is most convenient to throw exceptions in controllers that are caught in front controllers / middleware, and render a beautiful page (or form a beautiful json - depends on what is needed).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question