We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
I have slightly altered the code. response.StatusCode is always 'OK' even when there is a redirect. I m comparing the response.ResponseUri with the original URL and its seems to be working though for only initial two requests but starts timing out then. I have a list of 13000 urls to test in a loop and wondering if that is possible. My code as below
class Program { static void Main(string[] args) { string line; // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(@"C:\Users\MehtabM\Documents\URIFiles\ScotGov1.txt"); List<string> href = new List<string>(); while ((line = file.ReadLine()) != null) { href.Add(line); } file.Close(); HttpWebRequest request; HttpWebResponse response; foreach(string item in href) { request=HttpWebRequest.Create(item) as HttpWebRequest; request.Method = "GET"; request.ContentType = "text/xml"; response = request.GetResponse() as HttpWebResponse; if (response.ResponseUri.ToString() != item) { item.Replace(item, response.ResponseUri.ToString()); } response = null; } } }
If this is a list of URLs that all point to the same host, then it could be that the server is blocking your connections because you are hitting it with too many requests in a short period of time. You might try inserting a delay between each call.
As to the "response.StatusCode is always 'OK'" I'm not sure. The one I tested in the example returned HttpStatusCode.Found. If your method works, then it should suffice : )
mmalik15
ASKER
thanks again kaufmed for the help.
If I change the request.Method = "HEAD" This way we will not load whole page. Server only returns the headers and does not block subsequent requests.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
I have slightly altered the code. response.StatusCode is always 'OK' even when there is a redirect. I m comparing the response.ResponseUri with the original URL and its seems to be working though for only initial two requests but starts timing out then. I have a list of 13000 urls to test in a loop and wondering if that is possible. My code as below
Open in new window