asp.net-core - SignalR:无法在 Visual Studio 2017 项目中获取 js 库

标签 asp.net-core signalr asp.net-core-2.2 asp.net-core-signalr

尝试按照本教程让 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/

相关文章:

asp.net-mvc - AccessToken 不能超过 4K

asp.net-core - GZip 压缩不适用于 Azure 应用服务上托管的 ASP.NET Core 2.2 应用程序

c# - 将区域文件夹中的页面设置为asp.net core 2.2 MVC中的默认页面

mysql - 无法找到名称为 MySql.Data.EntityFrameworkCore 的提供程序程序集

javascript - ASP.NET Core 2.1 SignalR 未定义

asp.net - SqlException : Invalid column name 'NormalizedName' . 无效的列名 'ConcurrencyStamp'。无效的列名 'NormalizedName'

SignalR - 与来自多个局部 View 的寄存器的连接?

c# - 在 ASP.NET Core 2.2 中使用 InProcess 托管模型时,Serilog 不会将日志写入文件

c# - 如何在 ASP.NET Core Web API 项目中允许使用 IP 地址进行 CORS?

c# - .NET Core API REST C# List into List is null