tags:

views:

32

answers:

2

Before migrating from ASP.NET WebForms I had a very good way to monitor all my application errors in the Events Log (Administrative Tools).

But now after moving to asp.net MVC, all I get is the same mistake occurring every minute (something about Site Master). I know it's not right, because there are other mistakes, but they are not displayed. I purposefully put in division by zero operation, and it didn't track it.

I had to implement the OnException method of a controller, and send e-mails with error details which is very inconvenient.

How can I solve this problem?

+1  A: 

Try elmah, setup for asp.net mvc.

mxmissile
A: 

I implement the protected void Application_Error(object sender, EventArgs e) method in my global.asax for logging all errors to the EventLog in my ASP.NET MVC applications. Keep in mind that that you cannot create a new event source from within your application if your web server is running with the 'Network Service' credentials. A workaround is to create the event source manually (for testing purposes) by adding an event source in the registry using the regedit tool. The path to add it in is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application. Create a new key to add an event source. Later, you might want to include the creation of the key in your installer. It works perfectly for me. It should not matter if your controller action is invoked through Ajax or otherwise. The errors will still be logged. Hope it helps.

Jay Shanker