473,320 Members | 2,071 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,320 software developers and data experts.

address check

Hi

I am looking for a function in asp.net/vb.net to check a web address. I want
to check whether the url is really existing. For example
Function(http://www.prut.comm/ ) = false

thanks

B
Dec 17 '06 #1
2 1302
"Bert" <be****@gmail.comwrote in message
news:OH**************@TK2MSFTNGP04.phx.gbl...
I am looking for a function in asp.net/vb.net to check a web address. I
want to check whether the url is really existing. For example
Function(http://www.prut.comm/ ) = false
Apologies that this is in C#, not VB.NET, but it should be easy enough to
convert:
using System.Net;
using System.Text;

string strURL = "http://www.prut.comm";
using (WebClient objWebClient = new WebClient())
{
using (StreamReader objStreamReader = new
StreamReader(objWebClient.OpenRead(strURL)))
{
// do nothing here unless you want to do more than just "ping" the
URL
}
}

If no response is received from the URL, the above code will generate a
System.Net.WebExeception with the message (in this particular case):
"The remote name could not be resolved: 'www.prut.comm'"

Surround the above with a try...catch and check explicitly for a
System.Net.WebException.

N.B. there may be more elegant ways of "pinging" a URL...
Dec 17 '06 #2
Try this (from
http://geekswithblogs.net/azamsharp/...8/81251.aspx):

private bool DoesUrlExists(string url)
{
bool urlExists = false;
WebRequest req = WebRequest.Create(url);

try
{
HttpWebResponse response = (HttpWebResponse) req.GetResponse();
urlExists = true;
}
catch (System.Net.WebException ex)
{

}

return urlExists;
}
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Bert" <be****@gmail.comwrote in message
news:OH**************@TK2MSFTNGP04.phx.gbl...
Hi

I am looking for a function in asp.net/vb.net to check a web address. I
want to check whether the url is really existing. For example
Function(http://www.prut.comm/ ) = false

thanks

B

Dec 17 '06 #3

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

Similar topics

4
by: vishal | last post by:
how can i verify the email address entered by client??? is there any readily available function for that in php or mysql????? else suggest me some links for verifying email address enetered...
9
by: news | last post by:
There's all kinds of ways to validate an email address to make sure it's well formed and whatnot, but what about checking to see if it's a valid e-mail account? Like how you can use checkdnsrr()...
117
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
4
by: Andrew Banks | last post by:
I'm going to have an admin section to a site I'm developing using ASP.NET C# I want to restrict access to this directory based on username and password (I've got that bit done) but also upon the...
2
by: ArunPrakash | last post by:
Hi All, I have a case where i need to validate if the email address is valid before i send a mail. for this there are 2 parts.. * check the format of mail address - this is done * check the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.