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!