Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is the screenshot of runtime project that contains signalR.

https://i.stack.imgur.com/hzzEo.png[^]

There is no hubs file generated. I am getting the most common javascript error That is also shown in picture.
Please advice something on this. The code is the sample code from microsoft docs. Tutorial: Getting Started with SignalR 2 | Microsoft Docs[^]

What I have tried:

I searched and found many solutions but nothing seems to work. like changing reference src and etc.
Here is how I am referencing the script files.

C#
<script src="Scripts/jquery-3.3.1.min.js"></script>

    <!--Reference the SignalR library. -->
    <script src="Scripts/jquery.signalR-2.2.2.min.js"></script>
    <!--Reference the autogenerated SignalR hub script. -->
    <script src='<%: ResolveClientUrl("~/signalr/hubs") %>'></script>
Posted
Updated 11-Sep-18 22:18pm

1 solution

Finally got the answer. I was trying every possible thing I got on internet and then one thing worked. and that was in this line [HubName("myHub")].. I had this name as [HubName("MyHub")] before and so the error.

C#
[HubName("myHub")]

public class MyHub : Hub
{
  
    public void Send(string name, string message)
    {
        // Call the broadcastMessage method to update clients.
        Clients.All.broadcastMessage(name, message);
    }

You need to define HubName same as you used in javascript so that there wont be any confusion in getting client.

C#
var chat = $.connection.myHub;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900