Is it possible to use custom error pages with MVC site but not Web API?

前端 未结 3 1290
旧时难觅i
旧时难觅i 2020-12-08 02:29

I have an MVC project with a /api folder which contains my Web API controllers. I want the following things:

  • My MVC site to serve a custom error page when an e
3条回答
  •  不思量自难忘°
    2020-12-08 03:08

    I have not tested this, but how about writing the code to handle your MVC application errors, like shown here http://thirteendaysaweek.com/2012/09/25/custom-error-page-with-asp-net-mvc-4/ ?

    His code show that he is doing this at the application level (Global.asax), but I guess you could just as well trap exceptions at a lower level in the same way, with one method for MVC and another one for Web API.

提交回复
热议问题