title: Catching exceptions thrown in an asynchronous web service completed event handler
body: <p>Imagine a web service with a method that returns a Customer object, that takes a customer ID as a parameter, i.e.</p>
  
  <pre><code>[WebMethod]
  Customer GetCustomer(string customerId)
  </code></pre>
  
  <p>Now imagine that you're writing an ASP.NET app and you've generated a proxy for the service with the async operations.  You create an instance of the service, wire service.GetCustomerCompleted to your handler, OnGetCustomerCompleted, and call service.GetCustomerAsync("12345").</p>
  
  <p>In OnGetCustomerCompleted you apply logic to detect that no customer was found and throw a custom exception, or you want to throw the exception found in e.Error, e.g.:</p>
  
  <pre><code>void OnGetCustomerCompleted(object sender, GetCustomerCompletedEventArgs e)
  {
      if (e.Error != null)
          throw new ApplicationException("GetCustomer failed", e.Error);
  
      if (String.IsNullOrEmpty(e.Result.FirstName) &amp;&amp; String.IsNullOrEmpty(e.Result.LastName))
              throw new CustomerNotFoundException();
  }
  </code></pre>
  
  <p>(I've omitted the bits of code that sets up a Customer object and persists it through the calls.)</p>
  
  <p>You launch the call to GetCustomerAsync in Page_Load and expect to retrieve the result in a handler wired to Page.OnPreRenderComplete.</p>
  
  <p>My question is, how do you catch the exception in your page?  I know you can catch it with Global.asax's ApplicationError, but what if you don't want to navigate away from your page?</p>