VisualStudio运行正常,IIS部署后HttpClient无法连接求助
问题描述
- 本地通过Visual Studio运行程序时,HttpClient可正常连接目标服务;部署至Windows Server 2012的IIS后,执行
HttpClient.SendAsync时无限等待,无法解析目标域名https://app.xxxxxxx.com/。 - 服务器上Chrome浏览器可正常打开该目标页面,已尝试修改lmhost文件但无效,不清楚需在IIS还是Windows Server 2012中配置权限。
相关代码
var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://app.xxxxxxx.com/"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer ..........."); string contentText = $@"{{""app_id"":""{_vInfo._id}"",""app_secret"":""{_vInfo._secret}""}}"; using (HttpContent content = new StringContent(contentText, null, "application/json")) { request.Content = content; var response = await client.SendAsync(request); //<<<---------- 此处无限等待 response.EnsureSuccessStatusCode(); string _result = await response.Content.ReadAsStringAsync(); }
事件查看器记录
Event code: 3001 Event message: The request has been aborted. Event time: 15.11.2024 12:47:16 Event time (UTC): 15.11.2024 09:47:16 Event ID: 4d45d21891154f469c4ca24420c37d85 Event sequence: 4513 Event occurrence: 1 Event detail code: 0 Application information: Application domain: /LM/W3SVC/1/ROOT-8-133761375015957277 Trust level: Full Application Virtual Path: / Application Path: C:\inetpub\wwwroot\MyWeb\ Machine name: WIN22 Process information: Process ID: 7576 Process name: w3wp.exe Account name: NT AUTHORITY\SYSTEM Exception information: Exception type: HttpException Exception message: Request timed out. Request information: Request URL: https://myweb.com:443/ConnectSvc Request path: /ConnectSvc User host address: xxx.xxx.xxx.xxx User: Is authenticated: False Authentication Type: Thread account name: NT AUTHORITY\SYSTEM Thread information: Thread ID: 66 Thread account name: NT AUTHORITY\SYSTEM Is impersonating: False Stack trace: Custom event details:
内容的提问来源于stack exchange,提问作者VolkanCetinkaya
相关产品推荐
相关产品推荐

