473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Making a domain lookup in asp.net

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">
<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">&nbsp;</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">&nbsp;</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>
Aug 9 '06 #1
2 4081
"Christopher Brandsdal" <br*******@binaer.nowrote in
news:OJ**************@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 :(

Aug 9 '06 #2
When I use the C# code, it works fine! I just need to figure out how to
convert it to VB :-)
"Spam Catcher" <sp**********@rogers.comskrev i melding
news:Xn**********************************@127.0.0. 1...
"Christopher Brandsdal" <br*******@binaer.nowrote in
news:OJ**************@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 :(

Aug 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dan | last post by:
Hi, I'm planning to develop a small intranet to provide our organization with documents online. I've decided to do this using jsp/servlets using a tomcat server. For an operating system, I...
9
by: Mike McGee | last post by:
I am new to database apps, but I am making a db with access 2002. Here is what I have and what I would like for it to do. tblCustomers = holds customer info (Name, Address, City, State, Zip,...
2
by: martin | last post by:
Hi, I would like to validate an email address from .net. Now before you scream regular expression I would like something a bit better than this. I would like to validate the domain, and maybe...
16
by: Michael | last post by:
Does someone have a reliable routine to get the domain name of the current user of a web page? Something like NSLookup. I have no problem getting their IP address, but I also want the domaine...
2
by: johkar | last post by:
I am getting an Access denied error when I write to a new window. The situation and code are outlined below. I am setting the domain in the main window. The problem is that the window I am...
0
by: tim.mayo | last post by:
I'm trying to write a component in VB.NET that takes a user account and returns the Active Directory domain name of the user account. Since it's not a windows/web application, I can't use...
4
by: JB | last post by:
I am trying to get a list of all the active computers running on my domain. I'm writing some remote management style software with WMI, which works fine when i know the computer name, but i just...
6
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, We have two sites hosted on different servers and we have many pages on domain A which has many links(asp programs) to domain B. My question is if domain B server is in trouble, what is...
2
by: Tuncer Erhamza | last post by:
Hi! Another web application (domain) call our application. We want to determine in our application which domain call. Thanks.
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.