-1

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?

tshepang
  • 12,111
  • 21
  • 91
  • 136
John Smith
  • 11
  • 1
  • 1
  • 2

3 Answers3

1

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

Andy G
  • 19,232
  • 5
  • 47
  • 69
  • 1
    You should post the errors that you received. However, David has advised of a more significant issue for your circumstance. – Andy G Jul 21 '13 at 00:30
1

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?.

Community
  • 1
  • 1
David -
  • 2,009
  • 1
  • 13
  • 9
  • So there is no way around that? :\ – John Smith Jul 21 '13 at 00:26
  • I suppose you could attempt to clear cookies each time [SO link](http://stackoverflow.com/questions/912741/c-webbrowser-control-how-to-delete-cookies-from-windows-form) but I am not convinced about how effective this might be. I am suspicious that, if it could work, you would need to wait, and close/remove, each WB instance. – Andy G Jul 21 '13 at 00:39
  • Check this http://en.wikipedia.org/wiki/Application_Center_Test maybe it can help. – David - Jul 21 '13 at 01:19
0

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.

tinstaafl
  • 6,908
  • 2
  • 15
  • 22