如何从HttpResponseMessage获取IP地址?

时间:2019-04-29 03:46:26

标签: dotnet-httpclient

使用HttpClient(在System.Net.Http中)时,可以从HttpResponseMessage获取IP地址吗?

1 个答案:

答案 0 :(得分:2)

无法仅从HttpResponseMessage获取IP地址(可能是远程服务器的IP地址)。

HttpResponseMessage类型不公开这样的属性,,并且不包含具有此信息的任何类型。这意味着即使使用反射也无法回答该请求。

请参见reference source code for HttpResponseMessage.cs