I found a way to do this ...
Put this snippet of code in your base Page codebehind ... this should capture every error that gets thrown.
1 protected override void OnError(EventArgs e)
2 {
3 ScriptManager mgr = ScriptManager.GetCurrent(this);
4
5 System.Exception ex = this.Server.GetLastError();
6
7 if (mgr.IsInAsyncPostBack)
8 {
9 base.OnError(e);
10 }
11 else
12 {
13 this.Server.ClearError();
14
15 base.OnError(e);
16
17 Response.Write(<html><head><title>Error</title></head><body>");
18 Response.Write("<table class='Section'><tr class='SectionTitle'><td colspan='2'>Error Details</td></tr><tr><TD valign='top' class='FieldLabel' width='125px'>Error Message:</TD><td class='GenText'>");
19 Response.Write(ex.Message);
20 Response.Write("</TD></TR><TR><TD valign='top' class='FieldLabel'>Error Source:</TD><TD class='GenText'>");
21 Response.Write(ex.Source);
22 Response.Write("</TD></TR><TR><TD valign='top' class='FieldLabel'>Stack Trace:</TD><TD class='GenText'>");
23 Response.Write(ex.StackTrace);
24 Response.Write("</TD></TR><TR><TD colspan=\"2\"><a href=\"");
25 Response.Write(Request.RawUrl);
26 Response.Write("\">Return to previous page</a></td></tr></table></body></html>");
27 Response.End();
28 }
29 }
Then in your master page (or whatever page) codebehind capture the AsyncPostBackError from the ScriptManager tag (making sure to hook the OnAsyncPostBackError in the aspx page to the ScriptManager1_AsyncPostBackError):
1 protected void ScriptManager1_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)
2 {
3 if (e.Exception.Data["ExtraInfo"] != null)
4 {
5 ScriptManager1.AsyncPostBackErrorMessage =
6 e.Exception.Message +
7 e.Exception.Data["ExtraInfo"].ToString();
8 }
9 else
10 {
11 ScriptManager1.AsyncPostBackErrorMessage = "The following error occurred: " + e.Exception.Message;
13 }
14 }