Alex
Alex

Reputation: 36161

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 which is very important for me.

How can I get both the page and the error message?

Upvotes: 0

Views: 104

Answers (2)

Patrik Potocki
Patrik Potocki

Reputation: 316

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/

Upvotes: 1

Alex
Alex

Reputation: 36161

I solved by using Application_Error method.

More info here:

http://aspnetresources.com/articles/CustomErrorPages.aspx

Upvotes: 0

Related Questions