How to get ELMAH to work with ASP.NET MVC [HandleError] attribute?

前端 未结 8 2140
后悔当初
后悔当初 2020-11-22 02:53

I am trying to use ELMAH to log errors in my ASP.NET MVC application, however when I use the [HandleError] attribute on my controllers ELMAH doesn\'t log any errors when the

8条回答
  •  半阙折子戏
    2020-11-22 03:00

    A completely alternative solution is to not use the MVC HandleErrorAttribute, and instead rely on ASP.Net error handling, which Elmah is designed to work with.

    You need to remove the default global HandleErrorAttribute from App_Start\FilterConfig (or Global.asax), and then set up an error page in your Web.config:

    
    

    Note, this can be an MVC routed URL, so the above would redirect to the ErrorController.Index action when an error occurs.

提交回复
热议问题