C
Christopher Brandsdal
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..
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">
<aspropDownList 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>
</aspropDownList>
</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">
<aspropDownList 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>
</aspropDownList>
</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>
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..
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">
<aspropDownList 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>
</aspropDownList>
</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">
<aspropDownList 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>
</aspropDownList>
</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>