Get system ip code not working in server
<p>This code works on my system not in server please help me to fix this error. am not sure what is error..</p>

<p>This is my partial code...</p>

<pre><code>private IPAddress getMyCurrentIP()
{
     IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());

     if (host.AddressList.Length == 1)
     myCurrentIP = host.AddressList[0].ToString();
     else
     {
        foreach (IPAddress address in host.AddressList)
        {
          if (address.AddressFamily == AddressFamily.InterNetwork)
          {
            if (IsLocal(address))
            return address;
         }
      }
  }


  return null;
}

  public bool IsLocal(IPAddress address)
  {
  if (address == null)
  throw new ArgumentNullException("address");

  byte[] addr = address.GetAddressBytes();

  return addr[0] == 10
  || (addr[0] == 192 &amp;&amp; addr[1] == 168)
  || (addr[0] == 172 &amp;&amp; addr[1] &gt;= 16 &amp;&amp; addr[1] &lt;= 31);
  } 
</code></pre>

<p>please help me to fix this error...</p>
