2

The WebBrowser control automatically downloads the response from the server (when I only use the tradional WebBrowser.Navgiate()), how do I ignore the file, or refuse the download (as it seems to pause my program)?

Edit: This is the code:

webBrowser1.Navigate("url/phpFile.php?parameters");

And this is what I get when I run it:

enter image description here

Roni
  • 73
  • 2
  • 8
  • Why ignore it? You could ignore the response, but capture the file - http://stackoverflow.com/questions/13021709/how-to-capture-json-response-using-webbrowser-control – Zach P May 10 '15 at 15:14
  • It will not work for me because I'm first login and only then can access this page. – Roni May 10 '15 at 20:11

2 Answers2

2

1.Open Notepad and paste the following:

Windows Registry Editor Version 5.00;
; Tell IE 7,8,9,10 to open JSON documents in the browser on Windows XP and later.
; 25336920-03F9-11cf-8FD0-00AA00686F13 is the CLSID for the "Browse in place" .
;
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/json]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00

2.Save document as IE-Json.reg and then run it.

Tested on Windows 10 & Win 7

0

As a extention to NishantVerma.Me's awnser, this can be done programmatically. There is only one drawback, this has to be done with administrator privileges. My example is for a 32 bit application on a 64 bit device.

   private bool SetRegistery()
    {
        try
        {
            using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry64))
            {
                using (RegistryKey key = hklm.OpenSubKey(@"MIME\Database\Content Type\application/json", true))
                {
                    if (key != null)
                    {
                        key.SetValue("CLSID", "{25336920-03F9-11cf-8FD0-00AA00686F13}");
                        key.SetValue("Encoding", new byte[] { 0x80, 0x00, 0x00, 0x00 });
                    }
                }
            }
            return true;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
        return false;
    }
JJGAP
  • 161
  • 1
  • 2
  • 11