I\'m trying to add SignalR to my project (ASPNET MVC 4). But I can\'t make it work.
In the below image you can see the error I\'m receiving.
Your hub classes must be defined as public. For example:
class ChatHub : Hub
should actually be
public class ChatHub : Hub
Make sure you add
app.MapSignalR();
inside startup.cs and Configuration method, like this:
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
For Asp.net Core
Add
services.AddSignalR();
in ConfigureServices methode in your startup.cs
And add
app.UseSignalR(routes =>
{
routes.MapHub<ChatHub>("/chatHub");
});
in Configure methode in your startup.cs
Making the Hub class "public" solved it for me.
You should put SignalR and jQuery scripts, in correct order :
<script src="/Scripts/jquery-1.6.4.min.js" ></script>
<script src="/Scripts/jquery.signalR-1.1.4.js"></script>
<script src="/signalr/hubs"></script>