C# 如果服务器返回代码200,如何在不加载内容的情况下检测404页面?

C# 如果服务器返回代码200,如何在不加载内容的情况下检测404页面?,c#,http-status-code-404,http-status-code-200,C#,Http Status Code 404,Http Status Code 200,如果服务器应答代码为200,如何检测返回的404页?现在我正在检查内容长度,但它需要的时间太长。还有别的办法吗? 当前代码: HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); // Sends the HttpWebRequest and waits for a response. HttpWebResponse resp =

如果服务器应答代码为200,如何检测返回的404页?现在我正在检查内容长度,但它需要的时间太长。还有别的办法吗? 当前代码:

  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
                        }

您如何确定长度应为18795或更大?服务器在您的控制之下吗?如果是,为什么不返回404而不是200?我检查了404页面的内容长度。不,我,;我正在解析远程页面,它不在我的控制之下。