How to implement proper HTTP error handling in .NET MVC 2?

后端 未结 4 602
一个人的身影
一个人的身影 2020-11-29 19:29

I\'ve been struggling all day to implement error handling in my ASP.NET MVC 2 app. I\'ve looked at a variety of techniques, but none work properly. I\'m using MVC2 and .NET

4条回答
  •  一整个雨季
    2020-11-29 19:54

    This is a very old question. but I thought It's worth it if I introduce you to a much much cleaner way to handle Http Exceptions that I saw in dear "Jesse Webb's answer".

    The solution is to use the httpErrors element of the system.webServer section:

    
      
      
      
      
    
    

    You also can log all exceptions in this way. "Read the "Jesse Webb's answer"".

    This really feels much cleaner and also works as well as every other solution (without redirect).

    Note: This only works work in IIS 7 and and newer. (Because of the httpErrors element which was recently added.

提交回复
热议问题