Search code examples
dotnet-httpclient

How to get an IP address from an HttpResponseMessage?


Can one get an IP address from an HttpResponseMessage when using HttpClient (in System.Net.Http)?


Solution

  • There is no way to get an IP Address (presumably of the remote server) from only a HttpResponseMessage.

    The HttpResponseMessage type does not expose such a property and it does not contain any types which have this information. This means that the request can't be answered, even with the use of reflection.

    See the reference source code for HttpResponseMessage.cs.