0

How may I detect that was returned 404 page if server answer code 200? Now I checking content length, but it takes too long. Is there any other ways? Current code:

  HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
                        // Sends the HttpWebRequest and waits for a response.
                        HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
                        Stream s = resp.GetResponseStream();
                        StreamReader rs = new StreamReader(s);
                        string st = rs.ReadToEnd();
                        if (resp.StatusCode == HttpStatusCode.OK & st.Length > 18795)
                        {
                                handling answer here
                        }
andrey.shedko
  • 3,128
  • 10
  • 61
  • 121
  • How are you sure that the length should be 18795 or more? Is the server in your control? if yes, why not return a 404 instead of a 200? – swazza85 Feb 11 '15 at 10:00
  • I did checked the content length of that 404 page. No, I;m parsing remote page, it's not under my control. – andrey.shedko Feb 11 '15 at 10:08

0 Answers0