![](/img/trans.png)
[英]HttpClient connecting to azure server on network restore throws an error - unable to connect to remote server
[英]Azure web app - “HttpClient Unable to connect to the remote server”
我试图在我的azure Web应用程序中使用HttpClient
发出请求,但出现错误: Unable to connect to the remote server
如果打开kudu控制台,则可以使用以下命令成功发出请求:
Invoke-RestMethod -Uri https://mydomain/myendpoint
当我在本地运行程序时,它可以工作。
当我在azure Web应用程序中运行程序时,它不起作用。
HttpClient _client;
public MyHttpClient() {
_client = new HttpClient();
_client.BaseAddress = new System.Uri(ConfigurationManager.AppSettings["MyUri"]);
_client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); }
//...
var path = "/myendpoint";
var data = new Dictionary<string, string>();
data.Add("param1", value);
var response = await _client.PostAsJsonAsync(path, data);
更新1:
我尝试设置:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 |
SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => true;
但没有效果。
您无法从Azure Web App直接调用on = premise服务。 为此,您需要混合连接管理器。 看下面的帖子:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.