HttpWebRequest 错误 500(java.lang.NullPointerException)
我正在尝试获取 http://validator.w3.org/ 的内容C# 中的 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
如何解决此问题?
I am trying to get content of http://validator.w3.org/mobile/check?docAddr=www.facebook.com in C#. This is my code:
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();
The code works correctly with other pages, but with http://validator.w3.org/mobile/check?docAddr=www.facebook.com and a different docAddr
it's giving me a 500 error. I check with Fiddler and the error is:
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
How do I fix this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论