Thursday, June 24, 2010

Azure error handling

This isn't so much about error handling in azure as it is error handling in asp.net.  Ok the title kinda lied.. :) 

Adding error handling in asp.net is easy:

  1. Create an error page in your application (eg error/Error.aspx). 

  2. In the <customErrors/> config, set the defaultRedirect="error/Error.aspx" and voila!

  3. You have a couple of opportunities to handle the error (when it happens, in the page, or in the application):

    • In the page: public void Page_Error(object sender, EventArgs e)

    • In the application (Global.asax: protected void Application_Error(object sender, EventArgs e)



  4. Then you can access the actual exception via Server.GetLastError().GetBaseException();


So at work our exceptions get mailed.  Since azure currently doesn't have mail servers, we opted to use SendGrid which seemed quite ok.

Full guide here http://support.microsoft.com/kb/306355.

No comments:

Post a Comment