Sunday, February 17, 2013 #

ASP.NET SignalR “SCRIPT5007: Unable to get property 'client' of undefined or null reference” error

I was playing around with ASP.NET SignalR and while trying to use Hubs, stumbled upon this error.  Much as I would know that I was doing all the wrong things, I could recognize it has something to do with the line I had to embed in script

<script src="/signalr/hubs"></script>

When I added the above line, I was wondering where does this reference come from.  I assumed this must be one of the script bundling techniques of ASP.NET that would be resolved in the runtime from server.

However, found that the error occurred since I had not mapped the MapHubs in the Global.asax.

so, all I had to do was open up the Global.asax (create one if you don’t have it yet in the project) and in the Application_Start Method, add the following line.

 RouteTable.Routes.MapHubs();

With that, this error resolved.

Quick learning thought worth sharing.

Cheers!!!

Posted On Sunday, February 17, 2013 4:49 PM | Comments (190)