Get 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 that can be invoked gethostbyname, and we had to implement similar functions through components in the ASP, such as Aspdns and so on, Now MS has provided us with a new programming interface on ASP.net, so that we can easily implement such a similar function. The reason is that we have a DNS class in asp.net that we can easily implement the features we mentioned above in this class.
We can see that the following code is a very simple program, but he realized that we previously imagined in the ASP can not imagine the function.
<%@ 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 look for: <asp:textbox runat=server id=txtdomain/><asp:button runat=server id=do Text= "Find" OnClick=doClick/ >
</form>

Through the above code, we can see, in fact, as long as we asp.net the function of further excavation, he is really can achieve a lot of our very useful functions!

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.