How do I get the local server ip adress in asp.net?
I need to know the ip address of the server the application is running on. How do I get that in asp.net (c#)?
Status:
Open Nov 06, 2008 - 12:47 AM
.net, C#, ip address
4answers
Answers
Nov 06, 2008 - 12:59 AM
Urm not sure if you can use Request.ServerVariables with your code. Doing a Request.ServerVariables("LOCAL_ADDR") gets the ip.
Nov 06, 2008 - 02:06 AM
Ah, yes, that seems to do the trick.
Thanks
Nov 06, 2008 - 02:24 AM
Cool :)
Mar 06, 2014 - 10:29 PM
Hi you can follow the below program to find local servicer ip address:
public string GetIPAddress()
{
string strHostName = System.Net.Dns.GetHostName();
IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];
return ipAddress.ToString();
}
If you want to check external ip address Ip-Details.com here you can easily find out external ip
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
Add New Comment