How to make custom error pages work in ASP.NET MVC 4

前端 未结 11 2096
陌清茗
陌清茗 2020-11-22 12:25

I want a custom error page shown for 500, 404 and 403. Here\'s what I have done:

  1. Enabled custom errors in the web.config as follows:

    
    
            
11条回答
  •  孤街浪徒
    2020-11-22 13:25

    I had everything set up, but still couldn't see proper error pages for status code 500 on our staging server, despite the fact everything worked fine on local development servers.

    I found this blog post from Rick Strahl that helped me.

    I needed to add Response.TrySkipIisCustomErrors = true; to my custom error handling code.

提交回复
热议问题