Get the IP address of this host through the network domain name

Source: Internet
Author: User
Tags implement net domain domain name
In the Windows programming environment, we have an API function that can be invoked gethostbyname, which we had to implement through the component in the ASP
Similar functions, such as Aspdns, and so on, now Ms on the ASP.net to provide us with a new programming interface, so that we can easily achieve such a similar
The reason is that in the ASP.net gives us a DNS class, we can through this Class easy to implement what we mentioned above
Function.
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 that, in fact, we only have to asp.net the function of further excavation, he is really can achieve a lot of our
The very practical Function!


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.