Checking web site is running or not.

G

Guest

hello all,

I want to know how can I check whether a web site us running or not. I have
used HttpWebRequest but when I give a web site address, It takes few number
of seconds to throw exception if the web site is not running. Is there any
easy method of doing the same. I do *not* want to use IP to ping and check
the server.

Thanks
pradeep_tp
 
S

Saber

I'm not sure it is logical or not,
but if you use HttpWebRequest and you get no error when web site is running,
so you can use a try catch block:

Dim isRunning As Boolean = True
Try
'your code
Catch ex As Exception
If ex.Message = "The error message you get" Then isRunning = False
End Try

Sorry if I misunderstood your problem.
 
P

Peter Rilling

I think his problem was that he did not want to wait the few second for the
timeout to happen.

I doubt you can ping the website and get an instant response, if that was
the case than all browsers would return a DNS immediately instead of
continually waiting for a response.

And yes, you cannot rely on ping either because ping checks to see if the
machine if running, not if IIS is running.

Is there a specific reason you feel you cannot wait until a timeout happens?
 
G

Guest

Hi all,

Peter: I am using a timer inside a web serive. This timer will keep checking
5 websites whether they are running or not. I find that using HttpWebRequest,
if I request a web site which is down, it takes more than 15 seconds to
return me the error. The only reason I cannot wait for this much amount of
time is because I am using timer. I have 4 web sites and 1 ISAPI application
that I need to keep checking whether they are running.

John: Your suggestions is good. I suppose this will be useful when I only
need to check whether the IIS is runnig or not. What will happen if the IIS
is running fine and only one of the web sites is stopped. Is there any way to
check easily whether that particular web site is working fine.

Thanks.
pradeep_tp
 
J

John Timney \( MVP \)

You would first connect to the server on port 80 using telnet, then make a
GET request over telnet to the actual site. If it failed, your servers up
and your sites likely off.

Explanation of a telnet GET process here
http://www.dgate.org/~brg/bvtelnet80/

Of course you will need to confirm its actually faster than using the web
classes. I'm speculating that it will be much faster because its a much
lower level protocol than HTTP over TCPIP.
 
G

Guest

but what will happen in a situation where, for eg. there are 5 web sites
runnon on the web server and only one web site is down which I want to check.
In this case if i telnet to port 80 it will give me the status that the web
site is up which is not true
 
G

Guest

thanks john. I will try this out today. :)

John Timney ( MVP ) said:
You would first connect to the server on port 80 using telnet, then make a
GET request over telnet to the actual site. If it failed, your servers up
and your sites likely off.

Explanation of a telnet GET process here
http://www.dgate.org/~brg/bvtelnet80/

Of course you will need to confirm its actually faster than using the web
classes. I'm speculating that it will be much faster because its a much
lower level protocol than HTTP over TCPIP.

--
Regards

John Timney
Microsoft MVP

pradeep_TP said:
Hi all,

Peter: I am using a timer inside a web serive. This timer will keep
checking
5 websites whether they are running or not. I find that using
HttpWebRequest,
if I request a web site which is down, it takes more than 15 seconds to
return me the error. The only reason I cannot wait for this much amount
of
time is because I am using timer. I have 4 web sites and 1 ISAPI
application
that I need to keep checking whether they are running.

John: Your suggestions is good. I suppose this will be useful when I only
need to check whether the IIS is runnig or not. What will happen if the
IIS
is running fine and only one of the web sites is stopped. Is there any way
to
check easily whether that particular web site is working fine.

Thanks.
pradeep_tp
Peter Rilling said:
I think his problem was that he did not want to wait the few second for
the
timeout to happen.

I doubt you can ping the website and get an instant response, if that was
the case than all browsers would return a DNS immediately instead of
continually waiting for a response.

And yes, you cannot rely on ping either because ping checks to see if the
machine if running, not if IIS is running.

Is there a specific reason you feel you cannot wait until a timeout
happens?

"Saber" <saber[.AT.]oxin.ir> wrote in message
I'm not sure it is logical or not,
but if you use HttpWebRequest and you get no error when web site is
running,
so you can use a try catch block:

Dim isRunning As Boolean = True
Try
'your code
Catch ex As Exception
If ex.Message = "The error message you get" Then isRunning = False
End Try

Sorry if I misunderstood your problem.

hello all,

I want to know how can I check whether a web site us running or not. I
have
used HttpWebRequest but when I give a web site address, It takes few
number
of seconds to throw exception if the web site is not running. Is there
any
easy method of doing the same. I do *not* want to use IP to ping and
check
the server.

Thanks
pradeep_tp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top