有的程序在处理返回时会使用404返回出错信息,具体的出错内容会在Http的请求体中出现。对于dotnet缺省是不读取的,需要自己来处理。
对于通过http 404来返回错误后,要继续读取http的内容:
catch (WebException webEx)
{
using (Stream stream = webEx.Response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(stream))
{
string txt = reader.ReadToEnd();
}
}
}