如果服务器应答代码为 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
}