Obtain the IP address of the host through the network domain name

Source: Internet
Author: User

In the Windows programming environment, we have an API function GetHostByName that can be called. Previously we had to implement it through components in Asp.
Similar functions, such as AspDNS, etc. Now MS provides us with a new programming interface on ASP. Net, so that we can easily implement this similar
The reason is that a DNS Class is provided to us in Asp. Net. We can use this Class to easily implement what we mentioned above
Function.
We can see that the following code is a very simple program, but it implements functions that we previously imagined in Asp.
<% @ Import NameSpace = "System. Net" %>
<Script language = "C #" runat = server>
Protected void doClick (Object Src, EventArgs E ){

IPHostEntry hostInfo = DNS. GetHostByName (txtDomain. Text );
Showmsg. Text = hostInfo. AddressList [0]. ToString ();
}
</Script>
<Asp: Label runat = server id = showmsg/>
<Form id = testForm runat = server>
Network domain name to be searched: <asp: TextBox runat = server id = txtDomain/> <asp: Button runat = server id = do Text = "Search" onClick = doClick/>
</Form>

Through the above code, we can see that we only need to further explore Asp. Net functions, and he can indeed implement a lot of us.
Very practical features!
/*
Tofu is made of excellent products
Http://www.asp888.net bean curd technology station
If reprinted, Please retain the complete copyright information
*/


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.