I have an ASP.NET MVC application that includes functions invoked via SignalR. The ASP.NET application works fine and the data is updated for all clients in real time.
Can I create a WinForms application and connect to the same SignalR application and push data to my web applications through it? If so how can I connect to my SignalR Asp.NET MVC application through WinForms.
Sure! You can use the SignalR client to connect to the server running inside your ASP.NET application.
Check this for a full sample with a Console application (but it's the same for Winforms).
You need to use Microsoft.AspNet.SignalR.Client.Hubs
than you can create a connection like this:
var hubConnection = new HubConnection("http://localhost:53748");
var chat = hubConnection.CreateHubProxy("ChatHub");
chat.On<string, string>("broadcastMessage", (name, message) => { Console.Write(name + ": "); Console.WriteLine(message); });
hubConnection.Start().Wait();
chat.Invoke("Notify", "Console app", hubConnection.ConnectionId);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With