Saturday, April 28, 2012

get Client Ip Address Using Asp.net c#

to get Client Ip address use the following code
 if (Context.Request.ServerVariables["HTTP_VIA"] != null) // using proxy
                            {
                                                              Context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();  // Return real client IP.
                            }
                            else// not using proxy or can't get the Client IP
                            {
                                Context.Request.ServerVariables["REMOTE_ADDR"].ToString(); //While it can't get the Client IP, it will return proxy IP.
                            }

No comments:

Post a Comment