Note that there are some explanatory texts on larger screens.

plurals
  1. POSignalR in MVC3, timing and start/connect issues?
    primarykey
    data
    text
    <p>I am having a really weird issue with MVC3 and signalr.. I have a simple hub;</p> <pre><code>[HubName("test")] public class Test: Hub { public object GetStuff() { return new { dummy = "Test" }; } } </code></pre> <p>And some client-side code;</p> <pre><code>var connection = $.connection.test; connection.start(); connection.getStuff(); </code></pre> <p>This throws an error; </p> <p><strong>TypeError: Object # has no method 'start'</strong></p> <p>If I instead do</p> <pre><code>var connection = $.connection("test"); </code></pre> <p>I get a different error; </p> <p><strong>TypeError: Object # has no method 'getStuff' jquery-1.6.4.min.js:4</strong></p> <p><strong>POST <a href="http://localhost:63021/Controller/test/negotiate" rel="nofollow">http://localhost:63021/Controller/test/negotiate</a> 405 (Method Not Allowed)</strong></p> <p>Note its trying to negotiate under the controller for some reason?</p> <p>Is there some specific route I need to register? Some other magic I dont know about?</p> <p><strong>UPDATE</strong> So playing a bit with console -- the first version does in fact create an object that has getStuff() which i can call. But signalr throws up because i have to call start() first -- which doesn't exist! The second one creates an object that DOES have start(), but it doesnt have getStuff()..</p> <p><strong>UPDATE 2</strong> Tried doing $.connection.hub.start instead. This seems to work in the console, but not in the page onload.. Possibly start isnt finished before the hub call is made? Is it async?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload