Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am very new to SignalR. I am trying to make my ASP.Net website update an image for all clients after a button is clicked. After the button is clicked some computation is done at the server side(VB.NET) and ideally it would push an update to the image for all clients. When I run it, I don't get any errors but nothing happens. Any help would be greatly appreciated!


What I have tried:

Startup Page
Imports Microsoft.Owin
Imports Owin

<Assembly: OwinStartup(GetType(ImageHub.Startup))>
Namespace ImageHub

Public Class Startup
    Public Sub Configuration(ByVal app As IAppBuilder)
        app.MapSignalR()
    End Sub
End Class
End Namespace

Signal R Hub Class
Imports Microsoft.AspNet.SignalR

Namespace ImageHub
<Hubs.HubName("imageHub")>
Public Class ImageHub
    Inherits Hub
    Public Sub updateImage(src As String)
        Clients.All.updateImage(src)
    End Sub
End Class
End Namespace

VB.Net Code Behind
Dim contextHub = GlobalHost.ConnectionManager.GetHubContext("imageHub")      
contextHub.Clients.All.updateImage("www.imageurl.com")

Client Side
<script type="text/javascript">
    $.connection.hub.start().done(function () {
    });
    var updater = $.connection.imageHub;
     updater.client.updateImage = function (image_source) { 
         $('#img').attr('src',image_source); 
        };
    </script>
Posted
Comments
F-ES Sitecore 24-Apr-18 7:25am    
"www.imageurl.com" isn't a valid image url.

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