asp.net-core-signalr

How to read headers data in hub SignalR ASP.NET Core 2.1

天涯浪子 提交于 2021-02-20 09:47:26
问题 I'm trying to pass userId to hub on connection to signalR. This is how client sets up the connection: connection = new HubConnectionBuilder() .WithUrl("http://localhost:56587/hub", options => { options.Headers["UserId"] = loginTextBox.Text; }) .AddMessagePackProtocol() .Build(); How can I read this header in OnConnectedAsync() method in my hub? 回答1: To get Header Value as string: public override async Task OnConnectedAsync() { var httpCtx = Context.GetHttpContext(); var someHeaderValue =

How to read headers data in hub SignalR ASP.NET Core 2.1

折月煮酒 提交于 2021-02-20 09:47:00
问题 I'm trying to pass userId to hub on connection to signalR. This is how client sets up the connection: connection = new HubConnectionBuilder() .WithUrl("http://localhost:56587/hub", options => { options.Headers["UserId"] = loginTextBox.Text; }) .AddMessagePackProtocol() .Build(); How can I read this header in OnConnectedAsync() method in my hub? 回答1: To get Header Value as string: public override async Task OnConnectedAsync() { var httpCtx = Context.GetHttpContext(); var someHeaderValue =

Access SignalR from domain services and application layer

。_饼干妹妹 提交于 2021-02-11 13:32:53
问题 This is directly related to calling a SignalR Hub from the Application Service Layer in ASP.NET Boilerplate .NET Core version. As per the solution, SignalR hub implementation should be done in Web layer. But the dependency structure of the projects are like: App depends on Domain.Core Web.Core depends on App Web.Host depends on Web.Core Two questions: To be able to use the Hub in both Domain.Core and App projects, how should I wire it all up? If I define the interface in App layer with a null

What Is The Correct Way of Closing / Disconnecting An ASP.NET Core signalR Client Connection?

梦想与她 提交于 2021-02-11 13:12:49
问题 I am a new user struggling to close a secondary signalR client gracefully from an ASP.NET Core Blazor Server Page. I am setting up a secondary signalR client connection on first render of a Blazor Server Page. I am trying to close this secondary signalR client connection when the Page is closed via the browser tab. At the time of writing DisposeAsync does not seem to be triggered when the page is closed via the browser tab. However, the Dispose method IS triggered. Furthermore in Safari 13.0

What Is The Correct Way of Closing / Disconnecting An ASP.NET Core signalR Client Connection?

安稳与你 提交于 2021-02-11 13:12:16
问题 I am a new user struggling to close a secondary signalR client gracefully from an ASP.NET Core Blazor Server Page. I am setting up a secondary signalR client connection on first render of a Blazor Server Page. I am trying to close this secondary signalR client connection when the Page is closed via the browser tab. At the time of writing DisposeAsync does not seem to be triggered when the page is closed via the browser tab. However, the Dispose method IS triggered. Furthermore in Safari 13.0

What Is The Correct Way of Closing / Disconnecting An ASP.NET Core signalR Client Connection?

≯℡__Kan透↙ 提交于 2021-02-11 13:12:06
问题 I am a new user struggling to close a secondary signalR client gracefully from an ASP.NET Core Blazor Server Page. I am setting up a secondary signalR client connection on first render of a Blazor Server Page. I am trying to close this secondary signalR client connection when the Page is closed via the browser tab. At the time of writing DisposeAsync does not seem to be triggered when the page is closed via the browser tab. However, the Dispose method IS triggered. Furthermore in Safari 13.0

Asp .Net Core 2 + SignalR (1.0.0-alpha2-27025) + /signalr/negotiate 404 Error

陌路散爱 提交于 2021-02-07 14:15:40
问题 I add SignalR to ASP .Net Core 2 app packages "Microsoft.AspNetCore.All" Version="2.0.0" "Microsoft.AspNetCore.SignalR" Version="1.0.0-alpha2-27025" "Microsoft.AspNetCore.SignalR.Client" Version="1.0.0-alpha2-27025" "Microsoft.AspNetCore.SignalR.Client.Core" Version="1.0.0-alpha2-27025" "Microsoft.AspNetCore.SignalR.Common" Version="1.0.0-alpha2-27025" "Microsoft.AspNetCore.SignalR.Core" Version="1.0.0-alpha2-27025" public IServiceProvider ConfigureServices(IServiceCollection services) {

WPF SignalR Server

僤鯓⒐⒋嵵緔 提交于 2021-01-29 19:52:15
问题 I'm really stuck and need some help. I have a .NET Core 3.1 WPF application, which decodes basketball scoreboard data and now I need to send this data over to .html file. The .html file is opened once through CasparCG server as a template and needs to somehow have it's data update real-time. I currently thinking that the best way to do this is to have a SignalR server in the WPF app and a html template running a SignalR client. One of the requirements is that I have to be able to start and

How can I send the messages to specific user using user's id which stored in Mssql database?

荒凉一梦 提交于 2021-01-29 11:13:34
问题 I want to implement private chat system with Mssql Database.I want to one to one chat system. One user enter the receiver id which stored in database and message text, then send the message to Receiver . Then the message appears in receiver message area which has that receiver id. In my code works like this; Signalr produce connection id but this id changes every refresh, I want to constant id. How can I do This? This is my js code "use strict"; $(document).ready(() => { var connection = new

How do i map user connection and user id in signalr so that i can send a message to a specific user

放肆的年华 提交于 2021-01-29 02:26:00
问题 I want to send a private message to a user, i have created a hub but unfortunately i have no idea how to do it in signalr core, the documentation also doesn't have any article in it. 回答1: How do i map user connection and user id in signalr so that i can send a message to a specific user To achieve above requirement, please refer to the following example. ChatHub class: public class ChatHub : Hub { public static List<KeyValuePair<string, string>> ConnectedIds = new List<KeyValuePair<string,