question

DushanthaHettiarachchige-9640 avatar image
0 Votes"
DushanthaHettiarachchige-9640 asked Bruce-SqlWork commented

Connecting to Owin SignalR Hub using Blazor Application

Hi,

I have SignalR Hub written in .Net Framework and self-hosted using Owin/Katana.

Now I want to connect the aforementioned Hub in a .Net Core Blazor Web server app,

The problem is in Blazor I have to provide a URL, but Owin/Katana hosted hub does not have a URL to provide.

hubConnection = new HubConnectionBuilder()
.WithUrl(???)
.Build();

In .Net Framework I can connect using,

var connection = new HubConnection("http://localhost:8081/");

var testHub = connection.CreateHubProxy("MyHub");

How can I connect to the same Hub using Blazor Web server app?

dotnet-aspnet-generaldotnet-aspnet-core-blazor
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

BrandoZhang-MSFT avatar image
0 Votes"
BrandoZhang-MSFT answered Bruce-SqlWork commented

Hi @DushanthaHettiarachchige-9640,

According to your description, I suggest you could consider using the asp.net javascript signalr client library to connect to the asp.net signlar hubs ,since we couldn't use asp.net core signalr client library to call the asp.net signalr application.

More details about how to use signlar client javascript library, you could refer to this article. More details about how to invoke JavaScript (JS) method in blazor application by functions from .NET methods and .NET methods from JS functions. you could refer to this article.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your response,

If we are targetting only Windows then can I use Microsoft.AspNet.SignalR.Client in Blazor application instead of using Microsoft.AspNetCore.SignalR.Client?

0 Votes 0 ·
Bruce-SqlWork avatar image Bruce-SqlWork DushanthaHettiarachchige-9640 ·

No. .net core applications can not call 4.* framework code.

The main issue is the old signal/r and core signal/ are not compatible. there appears to no .net core client for the old signal/r. Also blazor server apps are signal/r hubs.


0 Votes 0 ·