Get IP Address in C sharp

Jak
Jak
908 Points
132 Posts

Hi,

how to get client ip address in c# or VB.net

Views: 9666
Total Answered: 1
Total Marked As Answer: 1
Posted On: 12-Apr-2015 20:58

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
4916 Points
27 Posts
         

Hi Jak,

Use following method in C#: 

public static string GetIPAddress()
{
 
return HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}

In VB.NET: 

Public Shared Function GetIPAddress() As String
 
Return HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")
 
End Function
Posted On: 12-Apr-2015 08:32
 Log In to Chat