Click here to Skip to main content
15,914,111 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi , i want to get Client Ip address ,
how can i achieve to this aim ?
Posted

I usually do something like this:

C#
private static string getUserIPAddress()
{
    string sReturn = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
    if (
            (sReturn == null)
            ||
            (sReturn.Length == 0)
            ||
            (sReturn.ToLower().Equals("unknown"))
        )
    {
        sReturn = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
    }
    if (sReturn == null) sReturn = string.Empty;
    return sReturn;
}
 
Share this answer
 
Any background research on your own? No? Pitty :(
How to get client IP[^]
 
Share this answer
 
Check this solution already posted here.

How to get client IP[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900