gpt4 book ai didi

c# - 无法从 Asp.Net WebApi 操作方法连接到网站 URL

转载 作者:太空宇宙 更新时间:2023-11-03 13:14:54 25 4
gpt4 key购买 nike

我正在尝试使用 Asp.Net Web Api 项目中的 WebClient 连接到 URL。我的目的是获取内容并创建网站缩略图。

示例代码:

using (var client = new WebClient())
{
var contents = client.DownloadString("http://www.google.com");
}

但是这个 WebClient 客户端对象在 WebApi 的情况下抛出超时异常并且同样适用于控制台应用程序。

请帮忙。

最佳答案

最后我在这里找到了答案:Web Request through Proxy using RestSharp

添加:

<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true"></defaultProxy>
</system.net>

我的网络配置为我修复了它。

关于c# - 无法从 Asp.Net WebApi 操作方法连接到网站 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26845404/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com