none
Code Inprivate Webbrowser vb.net RRS feed

  • Question

  • I wanted to create a program in vb.net InPrivate Webbrowser. Like InPrivate Browsing in Internet Explorer. No Clear Cache.

    My code:

        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            WebBrowser1.Navigate(TextBox1.Text)
        End Sub

    Thank.

    Monday, July 27, 2015 8:59 AM

All replies

  • Hi Blue else,

    We cannot run the WebBrowser control in InPrivate mode. It's not provided by WebBrowser control. If you want to open a URL in InPrivate mode, I suggest you open IE browser and set it's InPrivate mode to true. Code below is for your reference.

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
        Dim argument As String = String.Format("-private -nomerge {0}",TextBox1.Text)
    
        Process.Start("iexplore.exe", argument)
    
    End Sub
    

    Best Regards,

    Youjun Tang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, July 28, 2015 9:08 AM
    Moderator
  • - This is code from http://mdb-blog.blogspot.com/2013_02_01_archive.html

    Can you convert to VB.net? Thank.

    static void Main()
    {
        SuppressWininetBehavior();
    
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
    
    [System.Runtime.InteropServices.DllImport("wininet.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
    public static extern bool InternetSetOption(int hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);
    
    private static unsafe void SuppressWininetBehavior()
    {
        /* SOURCE: http://msdn.microsoft.com/en-us/library/windows/desktop/aa385328%28v=vs.85%29.aspx
            * INTERNET_OPTION_SUPPRESS_BEHAVIOR (81):
            *      A general purpose option that is used to suppress behaviors on a process-wide basis. 
            *      The lpBuffer parameter of the function must be a pointer to a DWORD containing the specific behavior to suppress. 
            *      This option cannot be queried with InternetQueryOption. 
            *      
            * INTERNET_SUPPRESS_COOKIE_PERSIST (3):
            *      Suppresses the persistence of cookies, even if the server has specified them as persistent.
            *      Version:  Requires Internet Explorer 8.0 or later.
            */
    
        int option = (int)3/* INTERNET_SUPPRESS_COOKIE_PERSIST*/;
        int* optionPtr = &option;
    
        bool success = InternetSetOption(0, 81/*INTERNET_OPTION_SUPPRESS_BEHAVIOR*/, new IntPtr(optionPtr), sizeof(int));
        if (!success)
        {
            MessageBox.Show("Something went wrong !>?");
        }
    }
    

    Can you convert to VB.net? Thank.


    • Edited by Blue else Wednesday, July 29, 2015 5:48 AM
    Wednesday, July 29, 2015 5:47 AM
  • Hi,

    Do you test the code? you could create a C# project, then test the code in this project. check if the WebBorwser is running in Inprivate Browsering.

    If it indeed works, you could find the way to convert this code to VB.

    Convert Tool: http://converter.telerik.com/.

    Also, as i know,  the  inprivate mode is not supported in WebBrowser.

    Omar

    Monday, August 3, 2015 5:23 AM