title: ASP.NET MVC async call a WCF service
body: <p>After complete of asynchronous call to WCF service I want set success message into session and show user the notification . </p>
  
  <p>I tried use two ways for complete this operation.</p>
  
  <p>1) Event Based Model.</p>
  
  <pre><code>client.GetDataCompleted += new EventHandler&lt;GetDataCompletedEventArgs&gt;(GetDataCompleted);
  client.GetDataAsync(id, client);
  private void GetDataCompleted(object obj, GetDataCompletedEventArgs e) 
  {
     this.SetNotification(new Notification() { Message = e.Result, Type =    NotificationType.Success });
  }
  </code></pre>
  
  <p>In MyOperationCompleted event i can set notification to HttpContext.Current.Session, but I must waiting before this operation will completed and can't navigate to others pages.</p>
  
  <p>2) IAsyncResult Model.
  In this way I can navigate to other pages and make asynchronous calls to wcf service, but in GetDataCallback method can't set notification, becouse session = null.</p>
  
  <pre>
  client.BeginGetData(id, GetDataCallback, client);
  private void GetDataCallback(IAsyncResult ar)
  {
      string name = ((ServiceReference1.Service1Client)ar.AsyncState).EndGetData(ar);
      this.SetNotification(new Notification() { Message = name, Type = NotificationType.Success });
  }
  </pre>
  
  <p>"Generate asynchronous operations" in service reference enabled.</p>
  
  <p>Please help me with this trouble. Thanks.</p>