问题
I 'm trying to parse RSS feeds and then display them on my website. My code seems to work correctly when parsing techcrunch & arstechnica RSS. But when I try to parse HackerNews RSS I get the an error.
XmlReader readXML;
readXML = XmlReader.Create(GetURL());
SyndicationFeed News= SyndicationFeed.Load(readXML);
readXML.Close();
return News;
I get the following error on readXML = XmlReader.Create(GetURL()); geturl is the url for rss.
The server committed a protocol violation. Section=ResponseStatusLine
Any suggestions why I 'm getting the above error. Thanks
回答1:
Check this link:
The server committed a protocol violation. Section=ResponseStatusLine
1.) You can add the following <httpWebRequest useUnsafeHeaderParsing="true" />
in the Web Config file to solve the server committed a protocol violation
<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>
2.)
Attention to all web developers who are using Skype! Make sure to uncheck the option for using port 80 and 443 from Tools\Options\Connection dialog.

来源:https://stackoverflow.com/questions/12801571/error-when-parsing-rss