One of the common tasks, for logging or authorization purposes, is to obtain the IP address of the client accessing your Web API.
There are different ways to achieve this depending on whether you are web hosting (through HttpContext) or whether you are self hosting (through WCF’s RemoteEndpointMessageProperty).
To avoid the redundant code, we can unify those approaches under a single extension method, which you can use across all your projects.