whadiz.com: What is?
Search Articles:     Home | About | Tools | Contact Us
Board Games
Online Games
Sql Server
Visual C# in ASP.Net
Web Design

Clever Facts Section

What is visitor's IP address | Determine IP address of person visiting my website

What is visitor IP address?

Asp.net with C# provides ways of determining IP addresses of visitors to your website. Simply check the server variables HTTP_X_FORWARDED_FOR, as well as REMOTE_ADDR. The server variable HTTP_X_FORWARDED_FOR will return the real IP address of the person. If the person is behind a proxy or router, the server variable REMOTE_ADDR will return the IP address of the proxy or router. 

What is the C# code to determine a visitor's IP address?

To determine a person actual IP address first check the server variable HTTP_X_FORWARDED_FOR:


If this returns nothing, check the IP address of the server or proxy of the person visiting by checking the server variable REMOTE_ADDR:


As an alternative to using REMOTE_ADDR, you may also use "UserHostAddress". The "UserHostAddress" property acts as a wrapper for REMOTE_ADDR:


What is the code for a function to determine a visitor's IP address?

Here is some example C# code:

public string Ip()
    string ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
    if (ipAddress == null || ipAddress == "")
        ipAddress = Request.ServerVariables["REMOTE_ADDR"];
    return ipAddress;

Link to this article:

Browse some more: Next Article | Next Fact | More Visual C# in ASP.Net Articles | More Clever Facts

Copyright © 2018 whadiz.com. All rights reserved.
whadiz.com: Determine IP address using C# | What is visitor's IP address | Determine IP address of person visiting my website
Home of the answer "what is"
Website designed by IT Trader & hosted by CMWeb

Centuries later, the IWC watch rolex replica was still able to rejoice at the original request of two Portuguese customers. In the 1930s, the prevailing fashion at that time was a small Art Deco style replica rolex watch, and the two customers demanded that IWC replica watches uk develop a large-scale replica watches with all the advantages of its ancestor's marine timer.