Pinging a Web service
we can ping against only an IPAddress, not with URL. so what we can do is just make use of HttpWebrequest class to achieve the same. the below console program is used to sniff the site.
using System.Net;
using System;
public class Sniffer
{
public static void Main()
{
try
{
string lcUrl = "http://www.abc.com";
// *** Establish the request
HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create(lcUrl);
// *** Set properties
loHttp.Timeout = 10000; // 10 secs
// pass Proxy string and bypass local machine if required.
WebProxy loProxy = new WebProxy("http://Proxyaddress",true);
loProxy.Credentials = new NetworkCredential("username","password");
loHttp.Proxy = loProxy;
// *** Retrieve request info headers
HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse();
loWebResponse.Close();
Console.WriteLine("Success ");
}
catch(Exception ex)
{
Console.WriteLine("Error : " + ex.Message);
}
}
}
we can ping against only an IPAddress, not with URL. so what we can do is just make use of HttpWebrequest class to achieve the same. the below console program is used to sniff the site.
using System.Net;
using System;
public class Sniffer
{
public static void Main()
{
try
{
string lcUrl = "http://www.abc.com";
// *** Establish the request
HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create(lcUrl);
// *** Set properties
loHttp.Timeout = 10000; // 10 secs
// pass Proxy string and bypass local machine if required.
WebProxy loProxy = new WebProxy("http://Proxyaddress",true);
loProxy.Credentials = new NetworkCredential("username","password");
loHttp.Proxy = loProxy;
// *** Retrieve request info headers
HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse();
loWebResponse.Close();
Console.WriteLine("Success ");
}
catch(Exception ex)
{
Console.WriteLine("Error : " + ex.Message);
}
}
}
No comments:
Post a Comment