Click here to Skip to main content
15,747,637 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Net Core app which sends SignalR notifications when certain events occur, my client ( Web app ) captures these notifications using SignalR client C# handlers. All working perfectly. I would like to have a Javascript client which does the same thing because I need to manipulate the DOM - I downloaded some Javascript which connects to the server fine, but never receives any notifications - this is the code

document.addEventListener('DOMContentLoaded', function ()
    var connection = new signalR.HubConnectionBuilder()
            skipNegotiation: true,
            transport: signalR.HttpTransportType.WebSockets

    connection.on("PGNotify", function (message)
        console.log("Notification received --> ", message);

    async function start() {
        console.log("Starting SignalR client");
        await connection.start();
        console.log("SignalR connected");

As I said earlier the code connects ok but never receives any notifications.
Any ideas guys ?

What I have tried:

What I show above and googling
Updated 10-Apr-23 21:07pm
0x01AA 8-Apr-23 9:18am    
pkfox 8-Apr-23 10:25am    
Hi thanks for your reply , If it was a CORS problem the c# code wouldn't work either and it does
0x01AA 8-Apr-23 12:37pm    
I was assuming your js runs in a browser. And from what I understand CORS is handled by the browser and only by it. But yes, I don't know so much in that field, was anyway only a wild guess *blush* ;)

I'm pretty sure that @RichardDeeming can solve that :D
Richard Deeming 11-Apr-23 3:15am    
CORS only applies to JavaScript, not to C#. :)
pkfox 11-Apr-23 4:58am    
Thanks Richard have you any idea on my other ( related ) question ?

1 solution

I cleared the browser cache and it started working - back to the original problem where the list item dissappears
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