Get IP Address in C sharp

Jak
Jak
Member
858 Points
132 Posts

Hi,

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

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

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
Teacher
4822 Points
23 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