c# probe

  • Thread starter Thread starter yqyq22
  • Start date Start date
Y

yqyq22

Hi all,
I would like code a program that check if my iis is up and running, I
think a probe is a good way, but I dont have idea how to implement this

probe and where begin.
moreover I would like that this Probe must be always active.
Is there a way to do this?
Please, could you give me some advice? class/methods
thanks a lot in advance!!!
 
see ths method. all you have to do is to put URL to machine where IIS
reside

public static bool IsOnLine()
{
bool flag1;
WebResponse response1;
WebRequest request1;
try
{
Uri uri1 = new Uri(@"http://www.contoso.com");
request1 = WebRequest.Create(uri1);
response1 = request1.GetResponse();
response1.Close();
request1 = null;
flag1 = true;
}
catch (Exception exception2)
{
ProjectData.SetProjectError(exception2);
Exception exception1 = exception2;
response1 = null;
request1 = null;
flag1 = false;
ProjectData.ClearProjectError();
}
return true;
}

Hope it helps


Galin Iliev[MCSD.NET]
www.galcho.com
 
yqyq22,

Are you trying to see if IIS is up and running, or are you trying to see
if you can connect? If you are trying to see if you can connect from a
particular machine, then that is the only way you can do it.

However, if you want to see if IIS is up (say, from an internal app),
you are better off getting the service controller on the machine it is on
and checking that. It's probably cleaner as well.

Hope this helps.
 
It should be noted that this error isn't completely correct.

When getting the response, a WebRequest could be thrown as a result of a
return code from the server. So, in other words, you could very well get a
response, and still throw.
 
you're right... for instance you will get error if IIS returns Error
404. this code is in case you need specific resourse and you just
check if IIS is exposing it.

depends of course if application needs resource or just to check if IIS
is up. both task could be made easily in one as having permanent,
static, small html page that will be use for check

I think it is much clearer now. Thank you

Regards
Galin Iliev[MCSD.NET]
 
ehm ehm, thanks a lot, sincerely I should check apache and soap
protocol (5 istance with different port, example http://myserver/...:90
, http://myserver/...:91 ) all running on windows2003 ( custom
application buied :-( ), hovewer I would like check the connection on
all 5 soap istances.
All 5 instances running as services (5 services, 1 parent and 4
children)
I know that is difficult because i don't know in details soap protocol
and apache, i think that servicecontroller is the better way maybe..
thanks again.
 
Back
Top