Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.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
C# WebBrowser Blogger.Com打开空白页_C# - Fatal编程技术网

C# WebBrowser Blogger.Com打开空白页

C# WebBrowser Blogger.Com打开空白页,c#,C#,我想浏览博客。com在我的节目中。。但当我登录到blogger时,它会打开一个空白页面。 WinFormIE11 WebBrowser1.Navigate("http://www.blogger.com"); 将以下代码粘贴到程序中的某个位置(可能在您的某个实用程序类中) 在表单构造函数中的InitializeComponent()之后调用函数SetBrowserFeatureControl() 然后尝试导航:WebBrowser1。导航(“http://www.blogger.com");

我想浏览博客。com在我的节目中。。但当我登录到blogger时,它会打开一个空白页面。 WinFormIE11

WebBrowser1.Navigate("http://www.blogger.com");

将以下代码粘贴到程序中的某个位置(可能在您的某个实用程序类中)

在表单构造函数中的InitializeComponent()之后调用函数SetBrowserFeatureControl()

然后尝试导航:
WebBrowser1。导航(“http://www.blogger.com");


.

您能从浏览器浏览此页面吗?
    #region "IE Fix"
    private void SetBrowserFeatureControl()
    {
        // http://msdn.microsoft.com/en-us/library/ee330720(v=vs.85).aspx

        // FeatureControl settings are per-process
        dynamic fileName = System.IO.Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);

        // make the control is not running inside Visual Studio Designer
        if (String.Compare(fileName, "devenv.exe", true) == 0 || String.Compare(fileName, "XDesProc.exe", true) == 0)
        {
            return;
        }

        SetBrowserFeatureControlKey("FEATURE_BROWSER_EMULATION", fileName, GetBrowserEmulationMode());
        // Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
        SetBrowserFeatureControlKey("FEATURE_AJAX_CONNECTIONEVENTS", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_ENABLE_CLIPCHILDREN_OPTIMIZATION", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_MANAGE_SCRIPT_CIRCULAR_REFS", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_DOMSTORAGE ", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_GPU_RENDERING ", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_IVIEWOBJECTDRAW_DMLT9_WITH_GDI  ", fileName, 0);
        SetBrowserFeatureControlKey("FEATURE_DISABLE_LEGACY_COMPRESSION", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_LOCALMACHINE_LOCKDOWN", fileName, 0);
        SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_OBJECT", fileName, 0);
        SetBrowserFeatureControlKey("FEATURE_BLOCK_LMZ_SCRIPT", fileName, 0);
        SetBrowserFeatureControlKey("FEATURE_DISABLE_NAVIGATION_SOUNDS", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_SCRIPTURL_MITIGATION", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_SPELLCHECKING", fileName, 0);
        SetBrowserFeatureControlKey("FEATURE_STATUS_BAR_THROTTLING", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_TABBED_BROWSING", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_VALIDATE_NAVIGATE_URL", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_WEBOC_DOCUMENT_ZOOM", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_WEBOC_POPUPMANAGEMENT", fileName, 0);
        SetBrowserFeatureControlKey("FEATURE_WEBOC_MOVESIZECHILD", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_ADDON_MANAGEMENT", fileName, 0);
        SetBrowserFeatureControlKey("FEATURE_WEBSOCKET", fileName, 1);
        SetBrowserFeatureControlKey("FEATURE_WINDOW_RESTRICTIONS ", fileName, 0);
        SetBrowserFeatureControlKey("FEATURE_XMLHTTP", fileName, 1);
    }

    private static void SetBrowserFeatureControlKey(string feature, string appName, uint value)
    {

        if (Environment.Is64BitOperatingSystem)
        {
            using (var key = Registry.LocalMachine.CreateSubKey(String.Concat("Software\\Wow6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\", feature), RegistryKeyPermissionCheck.ReadWriteSubTree))
            {
                key.SetValue(appName, (UInt32)value, RegistryValueKind.DWord);

            }
        }


        using (var key = Registry.CurrentUser.CreateSubKey(String.Concat("Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\", feature), RegistryKeyPermissionCheck.ReadWriteSubTree))
        {
            key.SetValue(appName, (UInt32)value, RegistryValueKind.DWord);
        }
    }

    private UInt32 GetBrowserEmulationMode()
    {
        int browserVersion = 7;
        using (var Key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Internet Explorer", RegistryKeyPermissionCheck.ReadSubTree, System.Security.AccessControl.RegistryRights.QueryValues))
        {
            dynamic version = Key.GetValue("svcVersion");
            if (null == version)
            {
                version = Key.GetValue("Version");
                if (null == version)
                {
                    throw new ApplicationException("Microsoft Internet Explorer is required!");
                }
            }
            int.TryParse(version.ToString().Split('.')[0], out browserVersion);
        }

        UInt32 mode = 10000;
        // Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10.
        switch (browserVersion)
        {
            case 7:
                mode = 7000;
                // Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.
                break;
            case 8:
                mode = 8000;
                // Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8
                break;
            case 9:
                mode = 9000;
                // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
                break;
            case 10:
                mode = 10000;
                // Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
                break;
            case 11:
                mode = 11001;
                // Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
                break;
        }

        return mode;
    }
    #endregion