How to add the SignalR client library in ASP.NET Core 2?


Hi, I'm using SignalR with .net core2 in Visual studio 2017 to send message to all users. But I don't know how can I add the SignalR client library.

My current javascript code is :

<script src="Scripts/jquery-1.6.4.min.js"
type="text/javascript"></script>
<script src="Scripts/jquery.signalR-0.5.2.min.js"
type="text/javascript"></script>
<script src="signalr/hubs" type="text/javascript"></script>
<script type="text/javascript">

var myHubProxy = $.connection.hub.CreateHubProxy("MyHub");
myHubProxy.on('ClientsListener', function (msg) {
// alert to test
alert(' message from server');
//$("#messageDisplay").text(msg);
})
$.connection.hub.start().done(function () {
myHubProxy.Invoke('MyServiceFunction');
})

</script>

In Which my project not contains those scripts :

<script src="Scripts/jquery-1.6.4.min.js"type="text/javascript"></script>
<script src="Scripts/jquery.signalR-0.5.2.min.js"type="text/javascript"></script>
<script src="signalr/hubs" type="text/javascript"></script>

Please how can add the SignalR client library. I was try this : But I remarked  no file clled Client_side library to add it .

notfound-min-signal-r

  • In Solution Explorer, right-click the project, and select Add > Client-Side Library.

  • In the Add Client-Side Library dialog, for Provider select unpkg.

  • For Library, enter @aspnet/signalr@1, and select the latest version that isn't preview.

Thanks in advance.


Asked by:- LuneAgile
0
: 46 At:- 11/15/2018 11:04:53 AM
ASP.NET SignalR adding-client-library






2 Answers
profileImage Answered by:- vikas_jk

Install using Nuget, Go to Tools->Nuget -> Nuget Package manager Console and use the command below

Install-Package Microsoft.AspNetCore.SignalR

Note: This file <script src="signalr/hubs" type="text/javascript"></script> is automatically created, you would not find it in any folder.

If you want to install it using Library Manager (LibMan) to get the client library from unpkg

Read this : https://docs.microsoft.com/en-us/aspnet/core/tutorials/signalr?view=aspnetcore-2.1&tabs=visual-studio#add-the-signalr-client-library

And you can easily add jQuery library, using Nuget or by adding jQuery cdn link.

1
At:- 11/15/2018 11:32:12 AM


profileImage Answered by:- LuneAgile

Hi Vikas_jk I have Installed the package  Microsoft.AspNetCore.SignalR .

But I can't find this file under my project This file <script src="signalr/hubs" type="text/javascript"></script>

1
At:- 11/15/2018 11:53:29 AM
Read my answer carefully, you will never find this file, it auto-generated 1
By : vikas_jk - at :- 11/15/2018 12:54:42 PM
Thanks so much Vikas_jk 0
By : LuneAgile - at :- 11/15/2018 12:58:42 PM





Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use