title: SignalR 2.0.0.0: $.connection is undefined
body: <p>I am trying to run my first SignalR v2 project but with no luck, $.connection is undefined. </p>
  
  <p>Here is the error from web console:</p>
  
  <ol>
  <li>Uncaught TypeError: Cannot read property 'chatHub' of undefined (anonymous function)</li>
  <li>k</li>
  <li>l.fireWith</li>
  <li>p.extend.ready</li>
  <li>D</li>
  </ol>
  
  <p>My hub:</p>
  
  <pre><code>using Microsoft.AspNet.SignalR;
  
  namespace InstantMessage
  {
      public class ChatHub : Hub
      {
          public void Hello()
          {
              Clients.All.hello();
          }
      }
  }
  </code></pre>
  
  <p>Startup.cs</p>
  
  <pre><code>using Microsoft.Owin;
  using Owin;
  
  [assembly: OwinStartup(typeof(InstantMessage.Startup))]
  namespace InstantMessage
  {
      public class Startup
      {
          public void Configuration(IAppBuilder app)
          {
              app.MapSignalR();
          }
      }
  }
  </code></pre>
  
  <p>Fontend:</p>
  
  <pre><code>&lt;head&gt;
      .....
      &lt;!--Script references. --&gt;
      &lt;!--Reference the jQuery library. --&gt;
      &lt;script src="~/Scripts/jquery-1.8.2.min.js"&gt;&lt;/script&gt;
      &lt;!--Reference the SignalR library. --&gt;
     &lt;script src="~/Scripts/jquery.signalR-2.0.0.js"&gt;&lt;/script&gt;
      &lt;!--Reference the autogenerated SignalR hub script. --&gt;
      &lt;script src="~/signalr/hubs"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;Instant Message Demo&lt;/h2&gt;
  
  &lt;div class="container"&gt;
          &lt;input type="text" id="message" /&gt;
          &lt;input type="button" id="sendmessage" value="Send" /&gt;
          &lt;input type="hidden" id="displayname" /&gt;
          &lt;ul id="discussion"&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  
  
      &lt;!--Add script to update the page and send messages.--&gt; 
      &lt;script type="text/javascript"&gt;
          $(function () {
              // Declare a proxy to reference the hub. 
              console.log($.connection);
  
              var chat = $.connection.chatHub;
              // Create a function that the hub can call to broadcast messages.
              chat.client.broadcastMessage = function (name, message) {
                  // Html encode display name and message. 
                  var encodedName = $('&lt;div /&gt;').text(name).html();
                  var encodedMsg = $('&lt;div /&gt;').text(message).html();
                  // Add the message to the page. 
                  $('#discussion').append('&lt;li&gt;&lt;strong&gt;' + encodedName
                      + '&lt;/strong&gt;:&amp;nbsp;&amp;nbsp;' + encodedMsg + '&lt;/li&gt;');
              };
              // Get the user name and store it to prepend to messages.
              $('#displayname').val(prompt('Enter your name:', ''));
              // Set initial focus to message input box.  
              $('#message').focus();
              // Start the connection.
              $.connection.hub.start().done(function () {
                  $('#sendmessage').click(function () {
                      // Call the Send method on the hub. 
                      chat.server.send($('#displayname').val(), $('#message').val());
                      // Clear text box and reset focus for next comment. 
                      $('#message').val('').focus();
                  });
              });
          });
      &lt;/script&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p>It seems like the js code in /signalr/hubs is correct, chathub is there and the autogeneration of the file works fine.</p>
  
  <pre><code>$.hubConnection.prototype.createHubProxies = function () {
          var proxies = {};
          this.starting(function () {
              // Register the hub proxies as subscribed
              // (instance, shouldSubscribe)
              registerHubProxies(proxies, true);
  
              this._registerSubscribedHubs();
          }).disconnected(function () {
              // Unsubscribe all hub proxies when we "disconnect".  This is to ensure that we do not re-add functional call backs.
              // (instance, shouldSubscribe)
              registerHubProxies(proxies, false);
          });
  
          proxies.chatHub = this.createHubProxy('chatHub'); 
          proxies.chatHub.client = { };
          proxies.chatHub.server = {
              hello: function () {
                  return proxies.chatHub.invoke.apply(proxies.chatHub, $.merge(["Hello"], $.makeArray(arguments)));
               }
          };
  
          return proxies;
      };
  </code></pre>
  
  <p>Should also mention that I installed Signalr from nuget and I am using VS2012.</p>