在尝试连接到Nuget时,我得到了下面的错误,然后我无法连接:

无法加载源的服务索引 https://api.nuget.org/v3/index.json。 发送请求时发生错误。 无法连接到远程服务器 连接尝试失败,原因是被连接方在一段时间后没有正确响应,或已建立连接 由于连接的主机未能响应68.232.34.200:443而失败

我可以在浏览器上访问https://api.nuget.org/v3/index.json。


当前回答

如果您得到此错误,但没有代理服务器,则可以转到

%userprofile%\AppData\Roaming\NuGet\NuGet.Config

并注释这行:

<config>
     <!-- Proxy settings -->
     <add key="http_proxy" value="host" />
     <add key="http_proxy.user" value="username" />
     <add key="http_proxy.password" value="encrypted_password" />
</config>

它为我工作,因为我得到了这个错误,但我没有代理服务器。

其他回答

有些开发环境可能既不使用浏览器也不使用代理。

一种解决方案是从nugget(例如https://dotnet.myget.org/F/dotnet-core/api/v3/index.json)下载包到共享目录,然后执行以下操作:

dotnet add package Microsoft.AspNetCore.StaticFiles -s "shared drive:\index.json"

我希望这对你有用。  

我尝试了这里列出的许多答案,但这些都不能解决问题。最后,我不得不在Windows中的凭据管理器中删除“Windows凭据”下的VSCredentials_xxx条目,并重新启动Visual Studio 2019。

在那之后——在下一次VS启动时——VS终于向我要了代理凭证——在输入它们之后,Visual Studio就可以访问互联网了。

(似乎VS很久以前就存储了我最初提供的代理凭据-但因为在我们公司,他们在强制执行3个月后更改密码-凭据不再有效。)

简单:

关闭VS2019 去c:\ users \you\ appdata \ roam \ nuget 删除文件NuGet。配置 重启VS2019

你可以开始了!

I had the same error message while scaffolding Identity to my ASP.NET Core MVC project. Since my connection was not behind a proxy, removing/editing proxy configurations didn't make sense. And I didn't want to delete a file or uninstall PMC either. While looking around I realized a "Clear All Nuget Cache(s)" button on Tools --> Options --> NuGet Package Manager --> General. After pressing the button I had to wait for some time for the operation to complete. After that I tried to scaffold the Identity again but it didn't work. Then I decided to restart VS and voila :)

如果你使用的是公司代理,并且在Mac上,只需确保你的http/https复选框被选中并应用。