I am having a problem with my SignalR project. I created a console to run SignalR, and then try to use it with my site (everything works in local hosting mode)
SignalRSelfHost
using System;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin.Hosting;
using Owin;
using Microsoft.Owin.Cors;
using Microsoft.AspNet.SignalR.Hubs;
namespace SignalRSelfHost
{
class Program
{
static void Main(string[] args)
{
string url = "http://localhost:8080";
using (WebApp.Start(url))
{
Console.WriteLine("Server running on {0}", url);
Console.ReadLine();
}
}
}
class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR();
}
}
[HubName("myHub")]
public class MyHub : Hub
{
public void Send(string name, string message)
{
Clients.All.addMessage(name, message);
}
}
}
index.html
<script src="Scripts/jquery-3.1.1.min.js"></script>
<script src="Scripts/jquery.signalR-2.2.1.min.js"></script>
<script src="http://localhost:8080/signalr/hubs"></script>
<script type="text/javascript">
$(function () {
var conn = $.hubConnection("http://localhost:8080/signalr");
var hubProxy = conn.createHubProxy('myHub');
conn.start().done(function () {
});
});
</script>
Some of the above were excelled because this is something that I tried too but didn't work.
Can someone tell me why I get the error: $. hubConnection is not a function (...)
user4575494
source
share