尝试按照本教程让 SignalR 基本工作: https://learn.microsoft.com/en-us/aspnet/core/tutorials/signalr?tabs=visual-studio&view=aspnetcore-2.2
我使用的是 Visual Studio 15.9.7
本教程包含以下说明,但是当我按照它们操作时,模式窗口会消失,没有任何类型的消息,而且我在任何地方都没有信号器 JavaScript 库。 lib/signalr 文件夹未提取到我的应用程序中。没什么。
我环顾四周,尝试找出手动下载它们的位置。没什么。
我尝试运行所有包控制台命令来尝试获取 signalR。像这样:npm install @aspnet/signalr
什么都没有。
是否有一种简单且行之有效的方法来获取这些 js 库?
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.
Add Client-Side Library dialog - select library
Select Choose specific files, expand the dist/browser folder, and select signalr.js and signalr.min.js.
Set Target Location to wwwroot/lib/signalr/, and select Install.
Add Client-Side Library dialog - select files and destination
LibMan creates a wwwroot/lib/signalr folder and copies the selected files to it.
最佳答案
首先,您可以尝试更新您的 Visual Studio,看看是否可以帮助解决问题。
此外,为了将SignalR客户端库添加到项目中,我们还可以使用LibMan Cli命令。
运行以下命令安装 LibMan(如果之前没有安装过)
dotnet tool install -g Microsoft.Web.LibraryManager.Cli
运行以下命令获取 SignalR 客户端库
libman install @aspnet/signalr -p unpkg -d wwwroot/lib/signalr --files dist/browser/signalr.js --files dist/browser/signalr.min.js
关于asp.net-core - SignalR:无法在 Visual Studio 2017 项目中获取 js 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58925535/