How to use 2 Webbrowser controls to use different cache/sessions - vb.net

I am using 2 different webbrowser controls in 2 different forms.
I open a page (www.dropbox.com/login) and login to the application.
When trying to open the same page in another webbrowser control on a different form, the application goes to the post login page, that is the application is already logged in.
How can i avoid this and do something such that both the webbrowser controls i have to login individually?

Prior to IE8 you could call InternetSetOption to end the session for that instance.
I don't think this is possible in IE8 and newer. Instances of the webbrowser control and Internet Explorer all share the same sessions and cookies.

Related

How to hide or cover a MS Access ActiveX Web Browser control?

I have a database in which users enter a value into Textbox1 on a form; the form also has an ActiveX Web Browser control (acxWebBrowser1), plus another blank Textbox2, and finally a command button. After the user enters text into Textbox1 and clicks the command button, the VBA code will navigate to a specific web page in acxWebBrowser1, enter the Textbox1 value into the web page form, and then obtain a result in the web page in acxWebBrowser1. The result is then grabbed by the VBA code and entered into Textbox2 on the database form.
What I need to be able to do is hide the ActiveX Web Browser control to (a) prevent the user from messing with the web page, and (b) to prevent the clutter and distraction of the ActiveX Web Browser since the VBA code does all the necessary interactions with the web page behind the scenes.
Problem is, I cannot get the acxWebBrowser1 to stay hidden behind a rectangle box control on the form because the browser automatically moves itself to the top of the stack of controls. If I reduce the size of the acxWebBrowser1 control to be very tiny, the web page does not function properly. If I make the web browser control not visible, then the code cannot grab the needed values. I cannot use a POST approach to avoid using the web browser. (I might be wrong about not being able to use POST--maybe someone can point me to how to do that if that is the way to go.)
How can I hide or put something on top of the web browser control?
Three hours later, it dawned on me how to accomplish hiding the ActiveX Web Browser but still get it to be accessible to the VBA code. Simple: Don't update the screen when running the code to access the ActiveX Web Browser and use the .Visible property to "show" the Browser Control when VBA needs to access it (but it won't be visible to the user if screen updating is off) and then hide the Browser Control when VBA is done accessing it.
Here's the code I used to accomplish that:
Application.Echo False 'turn off screen updating
Me.acxWebBrowser1.Visible = True 'make web browser control "visible" to VBA code
{do stuff, like: process web page}
Me.btnClickMe.SetFocus 'set focus on the button so we can hide the web browser control
Me.acxWebBrowser1.Visible = False 'make web browser invisible so user is not distracted
Application.Echo True 'turn screen updating back on
Me.Refresh 'refresh the screen; this is probably not necessary
Just be
absolutely sure to turn screen updating (echo) back on
You should send any error handling to code that sets Application.Echo True otherwise you will not be able to see or do anything if the code crashes after setting echo to False.

How to check if WebBrowser has been loading for a while?

In VB.NET, I have a windows form where I have a WebBrowser component. I am using proxies to navigate to pages and some proxies are dead/too slow so I want the program to switch to another proxy.
My question is, how can I detect if the WebBrowser has been trying to load the page for a set period of time e.g. it has been 5 seconds since it has been trying to load the page fully?
I am using HTML elements to automate the web browser btw, not sure if this is relevant information though.

MS Access Form with Webbrowser Control Popup New IE Window, Access 2010/VBA

I have struck with one issue not finding any workable solution. Googled a lot without any success…HELP PLEASE.
Situation: Using MS Access 2010, there is one Form with WebBrowser Control (Unbound) for conducting some search, when I click the results of the search a Pop-up new Internet Explorer window opens for the search result.
Requirement: I need “new Internet Explorer window” needs to be opened on existing WebBrowser Control..... NOT to open separately as new pop-up Internet Explorer window.
Kindly provide me solution (MS Access 2010/VBA) or workaround….
Regards,
Sandy
Can you open the form that you are opening in the WebBrowser Control in a new browser window outside of the application in order to test something. Check to see, if when you open the url, and then invoke the search, if the results open in a new window for that browser. If so, then check the target of the form within the first screen to get the name of the window that the page is trying to open the results in. If the target is specified, then you will need to write code to remove it when the page loads.
Just assign the new web address to your webbrowser control. something like this. Note it has to include equal sign and a hyper-link surrounded by quote.
Private Sub WebBrowser34_Click()
Me.WebBrowser34.ControlSource = "='www.google.co.uk'"
End Sub

Make multiple WebBrowser's without dragging them in file

Ok, so a program I am making involves using multiple webbrowsers with different cookies. It logs into the same site on several accounts. However, to log into several sites I need multiple webbrowsers running the same function, but I want this program to be able to log into as many accounts as needed, so I need to generate a webbrowser basically. Instead of putting it in the form, I need a code that generates a webbrowser on the form. Is this even possible?
You can use the Load event of the form to create new WebBrowser() controls and Add them to the Form's Controls collection.
However, it is not necessary to add them to the form in order to use them.
WebBrowser :MSDN
You can dynamically create many WebBrowsers but it wont work the way that you want. Each WebBrowser will act like a separate tab of an Internet Explorer. For more information you can check the following.
Hosting multiple WebBrowser controls in one window causes sessions to "cross": any solutions?.
Use a tabcontrol and put each webbrowser in a separate tabpage. You can easily declare a tabpage with a webbrowser and add or remove the tabpage as needed. Since each document that the webbrowser loads has it's own cookie collection, and the website is your own, you should be able to set up your website to accept multiple users from the same machine, at least temporarily for testing.

Select Input:File programmatically in Webbrowser control VB.net 2010

I have a website where I am filling form data through VB.Net 2010 through WebBrowser control.
I am able to set value for input:text, input:password, checkbox, select and able to submit form.
But I am not able to select input:file programmatically. I am also able to open
"Choose a File" Dialog.
How can I send file name to select and press OK button from VB.Net Code?
I am pretty sure this is a browser security feature to prevent malicious web-sites from auto-uploading random files from the user's website to themselves. Consider how dangerous it would be if any website could pull arbitrary files off the user's computer without any explicit action from the user.
Your best bet is probably going to be dumping the Web Browser control since it will limit you to its security model. Instead consider directly getting the web page and posting a response within your application.
The following .NET namespaces should come in handy for that:
System.Net.HTTPWebRequest
System.Net.TTPWebResponse