HttpWebRequest错误500(java.lang.NullPointerException)

时间:2011-06-03 22:22:30

标签: httpwebrequest

我想在C#中获取http://validator.w3.org/mobile/check?docAddr=www.facebook.com的内容。这是我的代码:

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.UserAgent = "A .NET Web Crawler";

WebResponse response = request.GetResponse();

Stream stream = response.GetResponseStream();

StreamReader reader = new StreamReader(stream);
htmlText = reader.ReadToEnd();

代码可以与其他网页一起正常使用,但是http://validator.w3.org/mobile/check?docAddr=www.facebook.com和另外docAddr代码会给我500错误。我与Fiddler核对,错误是:

HTTP/1.1 500 Internal Server Error
Date: Fri, 03 Jun 2011 22:18:36 GMT
Server: Jigsaw/2.2.6
Content-Length: 59
Content-Type: text/html
Via: 1.1 validator.w3.org
Vary: Accept-Encoding
Connection: close

Servlet has thrown exception:java.lang.NullPointerException

如何解决此问题?

0 个答案:

没有答案