title: Why is the hub context connection ID inaccessible at runtime in my VERY simple method?
body: <p>Let me start by saying this all works perfectly at the moment except for one thing - the notification update for the progress bar goes to all clients (as you would expect given that the code example I used sends to <code>...Clients.All</code>).</p>
  
  <p>All I want to do is send the notification back to the client that initiated the current call to the hub. That's it, nothing else.  There is no concept of "logging in" on this website so there's no user identity stuff to work with.</p>
  
  <p>My method is:</p>
  
  <pre><code>public void NotifyUpdates(decimal val)
  {
      var hubContext = GlobalHost.ConnectionManager.GetHubContext&lt;EventsForceHub&gt;();
  
      if (hubContext != null)
      {
          //"updateProgress" is javascript event trigger name
          await hubContext.Clients.All.updateProgress(val); 
      }
  }
  </code></pre>
  
  <p>So back in my view I subscribe to "updateProgress" and it works fine - the progress bar updates as desired. But if another client happens to be connected to the hub, when one runs the async task and causes the <code>NotifyUpdates</code> method to run, then ALL connected clients see the taskbar update, which is a bit confusing for them!</p>
  
  <p>In debug, if I inspect <code>hubContext</code> at runtime I can see a <code>Clients</code> property and that has a <code>Connection</code> property which has an <code>Identity</code> property with a unique GUID. Perfect!  Just what I want to use. But... I cannot access it!  If I try:</p>
  
  <pre><code>var currentConnection = hubContext.Clients.Connection;
  </code></pre>
  
  <p>...then I simply get a </p>
  
  <blockquote>
    <p>"does not contain a definition for 'Connection'"</p>
  </blockquote>
  
  <p>error, which I simply don't understand.</p>
  
  <p>I've tried accessing <code>Context.ConnectionId</code> from the method too, but <code>Context</code> is <code>null</code> at that point so I'm a bit confused.  The server method that uses <code>NotifyUpdates</code> to send information back to the client is called via a normal asp.net button, not via AJAX.</p>
  
  <p><strong>Clarification on structure</strong></p>
  
  <p>I think there is a degree of confusion here. It's a very simply webpage with an asp.net button control on it. The eventhandler for that button invokes an async method to return data from the server via a service call/repository.</p>
  
  <p>Inside the async method, it has to process each returned data line and make three or four remote web api calls. On each loop I make a call back to the <code>NotifyUpdates</code> SignalR method shown above with a percentage complete number so this can update back to the client via an eventhandler for the method name specified (<code>updateProgress</code> as shown above). There could be dozens of data lines and each data line requires several Web API calls to a remote server to add data. This can take several seconds per iteration, hence me sending back the "update progress" to the client via that <code>updateProgress</code> method call.</p>