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

前端 未结 11 2228
陌清茗
陌清茗 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:32

    You can get errors working correctly without hacking global.cs, messing with HandleErrorAttribute, doing Response.TrySkipIisCustomErrors, hooking up Application_Error, or whatever:

    In system.web (just the usual, on/off)

    
      
      
    
    

    and in system.webServer

    
    

    Now things should behave as expected, and you can use your ErrorController to display whatever you need.

提交回复
热议问题