Logging errors in ASP.NET (MVC) through the Custom Error
In my web.config I have the following:
<customErrors mode="RemoteOnly" defaultRedirect="/error.aspx"/>
When an error occurs, the user is redirected to /error.aspx?aspxerrorpath=/somepage where I can get user's name, name of the page, date, but... I can't get the error message!
I can get it via the OnException method, but then I won't be able to get the name of the page whi开发者_如何学编程ch is very important for me.
How can I get both the page and the error message?
I would suggest you to use
"ELMAH (Error Logging Modules and Handlers) is an application-wide error logging facility that is completely pluggable. It can be dynamically added to a running ASP.NET web application, or even all ASP.NET web applications on a machine, without any need for re-compilation or re-deployment"
http://code.google.com/p/elmah/
I solved by using Application_Error method.
More info here:
http://aspnetresources.com/articles/CustomErrorPages.aspx
精彩评论