locked
Compatibility Issues With SignalR and NetCore 3.1 RRS feed

  • Question

  • User1596943402 posted

    I am following this tutorial to create a real-time progress bar.  This article I am following is 4 years old, and I am using a different version of Net Core.  I am using the current version, which is ASP Net Core 3.1. 

    I believe the errors I am getting stem from the fact that I am using version 3.1 of Net Core.  This is the article I which I am using:

    https://www.codeproject.com/Articles/1124691/SignalR-Progress-Bar-Simple-Example-Sending-Live-D

    Everything seems to be running fine until I reach this part.

            public static void SendProgress(string progressMessage, double progressCount)
            {
                //IN ORDER TO INVOKE SIGNALR FUNCTIONALITY DIRECTLY FROM SERVER SIDE WE MUST USE THIS
                var hubContext = GlobalHost.ConnectionManager.GetHubContext<ProgressHub>();
    
                //CALCULATING PERCENTAGE BASED ON THE PARAMETERS SENT
                // var percentage = (progressCount * 100) / totalItems;
                var percentage = (progressCount);
    
                //PUSHING DATA TO ALL CLIENTS
                hubContext.Clients.All.AddProgress(progressMessage, percentage + "%");
            }
    
        }
    }

    The first issue is that I am getting "GlobalHost does not exist in the current context for this line of code":

    var hubContext = GlobalHost.ConnectionManager.GetHubContext<ProgressHub>();

    The second issue is that that I am getting "

    <div>Severity Code Description Project File Line Suppression State</div> <div>Error CS0119 'HubClientsExtensions.Clients<T>(IHubClients<T>, string)' is a method, which is not valid in the given context" for this line of code:

     hubContext.Clients.All.AddProgress(progressMessage, percentage + "%");

    Any suggestions would be kindly appreciated.

    Monday, August 24, 2020 6:28 PM

All replies