ASP.NET MVC Global error handling

后端 未结 3 1243
夕颜
夕颜 2021-02-08 09:37

I have a custom HandleError attribute that deals with errors on the MVC pipeline; I have an protected void Application_Error(object sender, EventArgs e)

3条回答
  •  一生所求
    2021-02-08 10:35

    To be correct to our visitors and the search engines, we should return meaningful HTTP status codes if errors occur, facing our site. It's not fair to return HTTP status code 200 on error, even if at the same time we return a view, explaining that an error occurred. if the user types in an incorrect address (the most frequent user fault), we should return HTTP status code 404 and not return or redirect to a View, where status code 200 will be returned.
    There is a short and clean recommendations summary HERE.

提交回复
热议问题