Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Created Issue: User IP Address in Web API RC [301]

$
0
0
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?

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>