Musielak Marek

Posted on Sunday, January 25, 2009 by Marek Musielak

Internal server errors handling

"Page could not be loaded". "Internal server error". Arghhhh ... When I see such a message on the website I feel like leaving the site hastily and never come back. The worse is when this is a site that I've built ... Ok, I can cope with this when I'm the one who tried to open the page. But what when I don't know that on the site that I'm responsible for, someone gets such a message every minute? And visitors one by one give up entering this page. Yeah, this is a serious problem.

Let's do something with this. Sure, we can create custom error page (like I described it for 404 error here). It would look nicely and inform user that our site encountered some difficulties and that we will deal with them soon surely. Yeah, but we're not able to fix the problem if we don't know about it. Solution seems to be pretty obvious - let's send an email to us informing that the page doesn't work. But what if when we'll try to open the page later, it will be up and running again? Or if the page crashes only in some particular circumstances that we won't be able to reproduce?

It would be really good to know about every error on the site no matter who tried to browse it. We can use Application_Error handler here. The Application_Error event handler is specified in the Global.asax file of the application. This handler is called whenever an unhandled exception is thrown in your application. So let's add this handler and send a notification error every time when something is wrong on our site.

Show code >

You probably won't need it in your development environment, but notification about erros should be a part of you production application for sure. Let me just give a short example:
Pretty big portal. Maintained and upgraded all the time. Up to 1,5 milion page views per day. One of the popular pages that hasn't been touched for a long time was down because of some very low level code change... For 2 weeks. After I added notification about application errors, I was able to fix it immediately. Without it... Most probably it would still be down.

You can tell me that you are brilliant developer, that your sites have no problems, that when you create something you don't have to worry about it anymore. I can pretend that I believe you. Maybe even you are perfect. However remember that hardware and software that you depend on are not.

Shout it
Read More »

Related Posts:

0 Responses to Internal server errors handling

Post a Comment