|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Making a domain lookup in asp.netI have found a script to lookup domain names, but it is written in C#. I want so bad to translate this to VB! Can anyone help me? I have tried myself. The script seems to run fine, but I never get any response on the whois-information.. Really hope somone can help me with this. Best regard, Christopher Brandsdal Here are the C# script followed by the one I tried to write in VB: ---------------- -- C# -- ---------------- <% @Page Language="C#" Debug="false"%> <% @Import Namespace="System.Net.Sockets" %> <% @Import Namespace="System.Text" %> <% @Import Namespace="System.IO" %> <% @Import Namespace="System.Text.RegularExpressions" %> <script language="C#" runat=server> public void btn_Click(object sender, EventArgs eArgs) { try { TcpClient objTCPC = new TcpClient(Request.Form["WhoisServer"], 43); string strDomain = Request.Form["DomainName"] + "\r\n"; byte[] arrDomain = Encoding.ASCII.GetBytes(strDomain); Stream objStream = objTCPC.GetStream(); objStream.Write(arrDomain, 0, strDomain.Length); StreamReader objSR = new StreamReader(objTCPC.GetStream(), Encoding.ASCII); lblResponse.Text = "<b>" + Request.Form["DomainName"] + "</b><br><br>" + Regex.Replace(objSR.ReadToEnd(),"\n","<br>"); objTCPC.Close();} catch(Exception ex) { lblResponse.Text = ex.ToString(); } } </script> <html> <head> <style> ..main {font-family:Verdana; font-size:12px;} ..title {font-family:Verdana; font-size:18px; font-weight:bold;} </style> </head> <body> <span class="title" align="center">WHOIS ASP.NET page</span> <form id="Form1" method="POST" name="MainForm" runat="server"> <table> <tr> <td class="main" align="right">Whois Server</td> <td class="main"> <asp:DropDownList class="main" id="WhoisServer" runat="server"> <asp:ListItem value="whois.networksolutions.com"> whois.networksolutions.com (.COM, .NET, .EDU)</asp:ListItem> <asp:ListItem value="whois.ripe.net">whois.ripe.net (Europe)</asp:ListItem> <asp:ListItem value="whois.norid.no">whois.norid.no (.NO) </asp:ListItem> <asp:ListItem value="whois.nic.uk">whois.nic.uk (.CO.UK)</asp:ListItem> <asp:ListItem value="whois.domain-registry.nl"> whois.domain-registry.nl (.NL)</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td class="main" align="right">Domain Name:</td> <td class="main"><input type="text" class="main" name="DomainName" value=""></td> </tr> <tr> <td class="main"> </td> <td class="main"><input type="Submit" id="btnSubmit" OnServerClick="btn_Click" value="Send" runat="server" /></td> </tr> </table> <br><br> <asp:Label class="main" id="lblResponse" runat="server"/> </form> </body> </html> ---------------- -- VB -- ---------------- <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <% @Import Namespace="System.Net.Sockets" %> <% @Import Namespace="System.Text" %> <% @Import Namespace="System.IO" %> <% @Import Namespace="System.Text.RegularExpressions" %> <script runat="server"> Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) dim objTCPC as TcpClient dim strDomain as string dim arrDomain as byte() dim objStream as Stream dim objSR as StreamReader try objTCPC = new TcpClient(Request.Form("WhoisServer"), 43) strDomain = Request.Form("DomainName") & "\r\n" arrDomain = Encoding.ASCII.GetBytes(strDomain) objStream = objTCPC.GetStream() objStream.Write(arrDomain, 0, strDomain.Length) objSR = new StreamReader(objTCPC.GetStream(),Encoding.ASCII) lblResponse.Text = "<b>" & Request.Form("DomainName") & "</b><br><br>" & Regex.Replace(objSR.ReadToEnd(),"\n","<br>") objTCPC.Close()catch ex as Exception lblResponse.Text = "Error!" end try End Sub </script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <span class="title" align="center">WHOIS ASP.NET page</span> <form id="Form2" method="POST" name="MainForm" runat="server"> <table> <tr> <td class="main" align="right">Whois Server</td> <td class="main"> <asp:DropDownList id="WhoisServer" runat="server"> <asp:ListItem value="whois.networksolutions.com"> whois.networksolutions.com (.COM, .NET, .EDU)</asp:ListItem> <asp:ListItem value="whois.ripe.net">whois.ripe.net (Europe)</asp:ListItem> <asp:ListItem value="whois.norid.no">whois.norid.no (.NO) </asp:ListItem> <asp:ListItem value="whois.nic.uk">whois.nic.uk (.CO.UK)</asp:ListItem> <asp:ListItem value="whois.domain-registry.nl"> whois.domain-registry.nl (.NL)</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td class="main" align="right">Domain Name:</td> <td class="main"><input type="text" class="main" name="DomainName" value=""></td> </tr> <tr> <td class="main"> </td> <td class="main"><input type="Submit" id="btnSubmit" OnServerClick="btn_Click" value="Send" runat="server" /></td> </tr> </table> <br><br> <asp:Label id="lblResponse" runat="server"/> </form> </body> </html> "Christopher Brandsdal" <brands***@binaer.no> wrote in A lot of whois servers block external queries... not even sure if you can news:OJsVr0#uGHA.1284@TK2MSFTNGP05.phx.gbl: > Hi! > > I have found a script to lookup domain names, but it is written in C#. > I want so bad to translate this to VB! Can anyone help me? I have > tried myself. The script seems to run fine, but I never get any > response on the whois-information.. query them directly anymore :( When I use the C# code, it works fine! I just need to figure out how to
convert it to VB :-) Show quoteHide quote "Spam Catcher" <spamhoneypot@rogers.com> skrev i melding news:Xns981AAEF22452Eusenethoneypotrogers@127.0.0.1... > "Christopher Brandsdal" <brands***@binaer.no> wrote in > news:OJsVr0#uGHA.1284@TK2MSFTNGP05.phx.gbl: > >> Hi! >> >> I have found a script to lookup domain names, but it is written in C#. >> I want so bad to translate this to VB! Can anyone help me? I have >> tried myself. The script seems to run fine, but I never get any >> response on the whois-information.. > > > A lot of whois servers block external queries... not even sure if you can > query them directly anymore :( >
MessageBox in Validating event cancels subsequent events
Referencing Controls created at run time. Class item not accessible because it's private... but it's not? End all running code of .dll Drawstring question... Description of Function ErrorProvider in .Net 2003 Passing parameters best practice How do I send null values to an integer type variable? Launch External Program |
|||||||||||||||||||||||