出于某种原因,我理解对特定网站(https://learningnetwork.cisco.com/people/mrollins?view=profile)的请求会产生一个reqsponse对象,其响应流包含网站的主干版本.
流在65536字节之后结束,等于2 ^ 16字节.我认为这是一个可疑的数字.这些请求抱怨内部服务器错误,我对此表示赞同,因为我已经验证了webbrowsers能够理解这个响应,并且完整的html包含在服务器的响应中.(使用提琴手)
我发现以前记录的问题在这里,这是不能令人满意的,原因很简单,它在这张票据上结束:
"我想我不得不希望错误不超过65536个字符......"
它确实如此.
解决方法很受欢迎,或者如果有人知道一个好的修复也很好.
using System;
using System.IO;
using System.Net;
using System.Web.UI;
namespace Example
{
public partial class _Default : Page
{
protected void Page_Load(object senderHidden, EventArgs eHidden)
{
//ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
var cookieContainer = new CookieContainer();
//Encoding enc = Encoding.UTF8;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://learningnetwork.cisco.com/people/mrollins?view=profile");
req.AllowAutoRedirect = false;
req.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
req.CookieContainer = cookieContainer;
req.Accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; …Run Code Online (Sandbox Code Playgroud)