WebException 里的 StatusCode 并不可靠
用以下代码判断了2.5万个域名,发现有一小部分结果有误。
// lots of other interesting code up here...
catch (WebException wex)
{
// typical http error
if (wex.Status == WebExceptionStatus.ProtocolError)
{
HttpWebResponse wrsp = (HttpWebResponse)wex.Response;
throw new HttpException((int)wrsp.StatusCode, wrsp.StatusDescription);
}
else
{
throw new HttpException(500, wex.Message);
}
}
// other interesting code goes down here...
GOOGLE到一个组件,测试很准,好像是收费的。 http://www.example-code.com/csharp/http_getStatus.asp

浙公网安备 33010602011771号