2
Reply

The remote server returned an error: (403)

Sathyam P

Sathyam P

Feb 1 2016 3:43 PM
372
any help on this? I am getting 403, 400, etc
 
try
{
ArrayList urlList = new ArrayList();
urlList.Add("http://engagepoint.com/");
urlList.Add("http://forensicfluids.com/");
urlList.Add("http://www.BizTechSolInc.com");
urlList.Add("http://cvisiontech.com/");
urlList.Add("http://www.msprojectexperts.com/");
foreach (string url in urlList)
{
try
{
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.AllowAutoRedirect = true;
webRequest.Timeout = 30000;//30 secs
webRequest.Method = "GET";
webRequest.ContentType = "text/html";
webRequest.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
string companyPresentUrl = response.ResponseUri.AbsoluteUri;
companyPresentUrl = companyPresentUrl.ToLower();
int httpStatusCode = (int)response.StatusCode;
string httpStatusDescription = response.StatusDescription;
System.Console.ForegroundColor = ConsoleColor.Green;
System.Console.WriteLine(url + "-" + httpStatusCode + "-" + httpStatusDescription);
}
catch (Exception exception)
{
System.Console.ForegroundColor = ConsoleColor.Red;
System.Console.WriteLine("Error: " + exception.Message);
}
}
}
catch (Exception exception)
{
System.Console.ForegroundColor = ConsoleColor.Red;
System.Console.WriteLine("Error: " + exception.Message);
}
 

Answers (2)