【发布时间】:2023-03-05 06:12:01
【问题描述】:
我正在使用此代码从 URL 读取内容:
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(urlAddress);
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)";
using (var resp = req.GetResponse())
{
var html = new StreamReader(resp.GetResponseStream()).ReadToEnd();
return html;
}
+ 在 app.config 我有:
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
在我的电脑中——我在其中编写程序运行良好,但是当我制作 exe 文件并尝试在我的网络服务器上运行时出现错误:
The server commited a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF
我该如何解决这个错误。
感谢您的帮助!
【问题讨论】:
-
以上链接都没有帮助,即使我在这里遇到同样的问题stackoverflow.com/questions/46469956/…
标签: c# web httpresponse