I've seen on various MS forums and Stack Overflow, the way to retrieve the user's IP address in Web API, requires falling back to the untestable (without mocking) static context object model by doing the following:
var ip = ((HttpContextWrapper) request.Properties["MS_HttpContext"]).Request.UserHostAddress;
or
var ip = ((HttpContextWrapper) request.Properties["MS_HttpContext"]).ServerVariables["REMOTE_ADDR"];
It seems counter to the very idea of Web API to have to return to using HttpContext.
Is this a temporary measure in the RC, or is there a better way to get this information?
var ip = ((HttpContextWrapper) request.Properties["MS_HttpContext"]).Request.UserHostAddress;
or
var ip = ((HttpContextWrapper) request.Properties["MS_HttpContext"]).ServerVariables["REMOTE_ADDR"];
It seems counter to the very idea of Web API to have to return to using HttpContext.
Is this a temporary measure in the RC, or is there a better way to get this information?