ASP.NET with C# and SQL SERVER , some vb.net . asp.net examples, asp.net codes, asp.net programs, c# code, sql server queries, important codes.
Friday, 19 October 2012
find ip address in asp.net c#
Step 1: Finding Visitor's IP Address in Asp.net, C# Code.
You can use following Code to find Visitors IP Address in Asp.net
string VisitorsIPAddr = string.Empty;//Users IP Address. if (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null){//To get the IP address of the machine and not the proxyVisitorsIPAddr = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();}else if (HttpContext.Current.Request.UserHostAddress.Length != 0){VisitorsIPAddr = HttpContext.Current.Request.UserHostAddress;}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment