Which HTTP Status Codes to cover for MVC error handling

后端 未结 4 2198
甜味超标
甜味超标 2021-02-13 15:09

I\'m currently developing custom error pages in my error handling code for my MVC application. But I\'m unclear as to which HTTP status codes I\'m meant to cover.

4条回答
  •  别跟我提以往
    2021-02-13 15:48

    Don't rely too much on http status codes.

    I have worked with a few bad web developers over the last couple of years that have incorrectly used them in their responses.

    I may look for codes within 200-299 for an indication of success. I may look for codes >500 to indicate a server failure.

    Beyond that, I use a selfish approach i.e. if you are making a request that your are expecting to have a package of data returned to you, then inspect the data. If there is no data or if the data is bad then I know for certain that there was a problem, because I didn't get what I needed to continue running my application in a nominal way.

提交回复
热议问题