Using signalR in .net 4.7 we were able to pass two variables from the client application to signalR server. Here is the code snippet:
public class MyHub : Hub
{
protected (string myVar1, string myVar2) GetValues() =>
(
Context.QueryString["MyVariable1"] ?? string.Empty,
Context.QueryString["MyVariable2"] ?? string.Empty,
);
}
$.connection.hub.qs = {'MyVariable1' : 'val1', 'MyVariable2' : 'val2'};
You can access the HttpContext
in your hub like this:
var httpContext = Context.Connection.GetHttpContext();
and then use httpContext.Request.Query["MyVariable"]
to get the variable value