How To Get IP Address Of A System using ASP.NET

First add namespace:

using System.Net;

Code in ASPX page:
<html xmlns=””&gt;
<head runat=”server”>
<title>Getting Ip Address</title>
<form id=”form1″ runat=”server”>
<asp:Label ID=”Label1″ runat=”server”></asp:Label>
Code Behind:
protected void Page_Load(object sender, EventArgs e)
string IP;
IP = Dns.GetHostName();
IPHostEntry ipEntry = Dns.GetHostByName(str);
IPAddress[] addr = ipEntry.AddressList;
for (int i = 0; i < addr.Length; i++)
Label1.Text =  “IP Address:” + addr[i].ToString();