Format:
Recent snippets matching tags of Get user's IP
/* Note to reader: There are two server variables of interest; REMOTE_ADDR and HTTP_X_FORWARDED_FOR. As many visitors access the internet via a third party (ie their ISP), REMOTE_ADDR does not always contain their IP address... it contains their ISP's address. If this is the case, most browsers then store the users IP address in the HTTP_X_FORWARDED_FOR variable. So, first, we check HTTP_X_FORWARDED_FOR, and then if that is empty, we try REMOTE_ADDR instead: */ string IP_Address = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if(String.IsNullOrEmpty(IP_Address)) {
105 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
