Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
protected void btnSubmit_Click(object sender, EventArgs e)
{

string strHostName = string.Empty;
strHostName = Dns.GetHostName();
IPHostEntry ipEntry = Dns.GetHostByName(strHostName);
IPAddress[] addr = ipEntry.AddressList;
for (int i = 0; i < addr.Length; i++)
{
txtIPs.Text = ("IP Address " + i + addr[i].ToString() + ", HostName: " + strHostName);
}

SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConStr"]);
SqlDataAdapter da = new SqlDataAdapter("Insert Into pew(name,ip)values('"+txtName.Text+"','" +txtIPs.Text+ "')", con);
DataSet ds = new DataSet();
da.Fill(ds);
txtName.Text = "";
lblStatus.Text = "Data Successfully Inserted";

}

Please Give me the code of get the host name when i put the website in IIS Server its urgent.I have already use this code & get the computer name but when host in IIS than it display only server name. i want to know everyone computer name which i forward the link plz
Posted
Updated 29-Oct-13 19:15pm
v4

1 solution

You are going in wrong direction and should rather review your architecture. From the standpoint of the Web, client's "computer names" simply don't exist, there is no such notion. And a Web applications don't have access to clients' hosts, by apparent reasons of safety.

—SA
 
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