I'm building a Web.Api (mvc & web.api) and try to get the clients ip adress with this code..
[System.Web.Http.HttpPut]
public HttpResponseMessage Update([FromBody] BookInformation bookStatus)
{
  // Stuff...
  // Retrieve clients IP#
  var clientIp = (System.Web.HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request.UserHostAddress
}
But I get this error:
'System.Web.HttpRequestBase' does not contain a definition for 'Properties' and no extension method 'Properties' accepting a first argument of type 'System.Web.HttpRequestBase' could be found (are you missing a using directive or an assembly reference?)
What am I missing here?
                        
According to the exception message it is saying that
Requestis of typeSystem.Web.HttpRequestBaseandPropertiesdoes not exist, which would be accurate for that class. This looks like you are mixing MVC and WebApi Controllers.the
System.Web.HttpRequestBase Requestyou are referencing is part of MVCController.Requestbut your method structure looks like it is suppose to be part of a Web ApiSystem.Web.Http.ApiControllerwhich has aSystem.Web.Http.HttpRequestMessage Requestproperty as well.Make sure you are inheriting from the correct controller.
I've used this extension helper to get the client ip with an
ApiControllerAnd used like this