Get IPAddress and HostName From PC or Laptop
Get the IPAddress and HostName From Pc Or Laptop Button Click in Asp.Net C#.
DEMO
Download Coding
Download
HTML COIDING
First - Add New - Form - Select Label,Textbox,Button From ToolBox
Next - Add Namespaces - Network Call Ip Address for PC
Next - Run [F5] - Button Click - Show the Ip Address
Get the IPAddress and HostName From Pc Or Laptop Button Click in Asp.Net C#.
DEMO
Download Coding
Download
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<p>
<asp:Label ID="Label1" runat="server" Text="IPAddress"></asp:Label>
<asp:TextBox ID="txtIPAddress" runat="server"></asp:TextBox>
<asp:Label ID="Label2" runat="server" Text="HostName"></asp:Label>
<asp:TextBox ID="txtHostName" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />
<div>
</div>
</form>
</body>
</html>
C# CODING
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Sockets;
using System.IO;
public partial class IPGET : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
GetComputer_LanIP();
}
protected string GetComputer_LanIP()
{
string HostName = System.Net.Dns.GetHostName();
IPHostEntry ipEnt = System.Net.Dns.GetHostEntry(HostName);
foreach (IPAddress ipAddress in ipEnt.AddressList)
{
if (ipAddress.AddressFamily.ToString() == "InterNetwork")
{
txtIPAddress.Text =
ipAddress.ToString();
txtHostName.Text =
ipEnt.HostName.ToString();
return ipAddress.ToString();
}
}
return "-";
}
}
Next - Add Namespaces - Network Call Ip Address for PC
0 comments:
Post a Comment