title: Calling a client method from C# code in Generic Handler, SignalR
body: <p>I've the following <code>Hub</code>:</p>
  
  <pre><code>public class ImageHub : Hub {
      public void LoadTheImage(String id, String imageUrl) {
          Clients.All.loadReadyImage(id, imageUrl);
      }
  }
  </code></pre>
  
  <p>And the following JavaScript code on the client side.</p>
  
  <pre><code>$(function () {
      var loadImage = $.connection.imageHub;
      loadImage.client.loadReadyImage = function (id, imageUrl) {
      alert(id + " is ready. Url: " + imageUrl); //this will be much more than an alert.
      };
  });
  </code></pre>
  
  <p>And got the following code on .ashx.cs file, which is a generic handler:</p>
  
  <pre><code>public void ProcessRequest(HttpContext context) {
      //do some stuff here
      var imageContext = GlobalHost.ConnectionManager.GetHubContext&lt;ImageHub&gt;();
      imageContext.Clients.All.loadReadyImage("imageOne", imageUrl);
  }
  </code></pre>
  
  <p>The whole this is intended to call a client side code when Generic Handler completes its process.
  But it is not working. After the Handler finishes its work, the alert is not showing on the browser.</p>
  
  <p>But when I change the client side code to the following, the alert is showing up. </p>
  
  <pre><code>$(function () {
      var loadImage = $.connection.imageHub;
      loadImage.client.loadReadyImage = function (id, imageUrl) {
          alert(id + " is ready. Url: " + imageUrl);
      };
      $.connection.hub.start().done(function () {
          loadImage.server.loadTheImage('my_id', 'image_url');
      });
  });
  </code></pre>
  
  <p>However, I need to call the function not from the client side, but need to call client side function from server side.</p>
  
  <p>How can I do this?</p>
  
  <p>Thanks everybody.</p>