Get IP Address in C sharp

Jak
Jak
Member
364 Points
152 Posts

Hi,

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

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

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
Moderator
1172 Points
211 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