Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webbrowser控件的InnerText中大JSON的C#问题_C#_.net_Json_Internet Explorer 11_Webbrowser Control - Fatal编程技术网

Webbrowser控件的InnerText中大JSON的C#问题

Webbrowser控件的InnerText中大JSON的C#问题,c#,.net,json,internet-explorer-11,webbrowser-control,C#,.net,Json,Internet Explorer 11,Webbrowser Control,我无法在Webbrowser控件中加载大的JSON。使用IE11和此注册表加载JSON,而不是下载JSON [HKEY\U CLASSES\U ROOT\MIME\Database\Content Type\application/json] “CLSID”=“{25336920-03F9-11cf-8FD0-00AA00686F13}” “编码”=十六进制:08,00,00,00 如果我下载该文件,它有7.329.068个字符。 如果我在webbrowser控件(或WebClient)中加载它

我无法在Webbrowser控件中加载大的JSON。使用IE11和此注册表加载JSON,而不是下载JSON

[HKEY\U CLASSES\U ROOT\MIME\Database\Content Type\application/json]
“CLSID”=“{25336920-03F9-11cf-8FD0-00AA00686F13}”
“编码”=十六进制:08,00,00,00

如果我下载该文件,它有7.329.068个字符。 如果我在webbrowser控件(或WebClient)中加载它并访问webBrowser2.Document.Body.InnerText,它只有2.634.268个字符

有趣的是,文件没有被切碎。文件中缺少子元素。已在记事本++中选中

最大的问题是,即使没有注册表解决方案和webclient下载,文件也不完整

我必须使用webbrowser控件,因为在这种情况下很难处理会话。JSON是一个1行文件,具有超过500万个字符。JSON文件通过JavaScriptSerializer反序列化,并对给定JSON执行perfekt

        private void GetJsonView(string url_)//object sender, EventArgs e)
        {
            webBrowser2.Navigate(new Uri(url_));
            webBrowser2.Navigate(url_);
        }

        private void webBrowser2_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            innerText = webBrowser2.Document.Body.InnerText;

            JavaScriptSerializer test = new JavaScriptSerializer();
            test.MaxJsonLength = Int32.MaxValue;
            sicht = test.Deserialize<View>(innerText);

        }

目前我还不知道IE为什么要“隐藏”一些节点。无论文件是保存还是直接解析为字符串到我的方法。主要目标是接收整个有效负载,我不知道如何实现。

您是否尝试过在webBrowser2\u DocumentCompleted事件中设置断点并检查内部文本。此外,您还可以尝试使用F12开发工具检查IE浏览器中的html元素。然后,比较InnerText值。您是否尝试过在webBrowser2_DocumentCompleted事件中设置断点并检查InnerText。此外,您还可以尝试使用F12开发工具检查IE浏览器中的html元素。然后,比较InnerText值。
        private void webBrowser2_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            if (e.Url.Segments[e.Url.Segments.Length - 1].EndsWith("/"))
            {
                e.Cancel = true;
                string filepath = null;

                saveFileDialog1.FileName = e.Url.Segments[e.Url.Segments.Length - 1];
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    filepath = saveFileDialog1.FileName;
                    WebClient client = new WebClient();
                    client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
                    client.DownloadFileAsync(e.Url, filepath);
                }
            }
        }