Click here to Skip to main content
15,912,082 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to get LAN IP address in asp.net
by programetically
plz do not suggest
Request.servervariable["ramote_addr"]
or
Dns.gethostname like this
Posted

try with following code

C#
Request.Params["REMOTE_ADDR"];
 
Share this answer
 
Comments
Uday P.Singh 23-Aug-11 5:44am    
good one my 5!
You can use Dns.GetHostAddresses[^]
C#
IPAddress[] ipList = Dns.GetHostAddresses(Dns.GetHostName());
 
Share this answer
 
Comments
Surendra Tarai 23-Aug-11 6:29am    
But it will give server ip not local ip? i asked u how to get local ip
like 192.168.1.104
Try this :

System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].GetIPProperties().UnicastAddresses[0].Address


The first index is if you have multiple network cards and the second index is if you have multiple ip addresses on the same network card.

Also, check this http://www.csharp-examples.net/local-ip/[^]

Hope this helps.
All the best.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900