0

I created a C# webbrowser with proxies, when I import proxies in textbox2. It gets one by one and go to the given URL. If I input 50 proxies, webbrowser should go 50 times (1 visit per each proxy).

I coded it but website display only one time for last proxy.

here the code

    private void button1_Click(object sender, EventArgs e)
    {
        string[] ipaddress = textBox2.Text.Split('\n');
        for(int i=0;i<Convert.ToInt32(ipaddress.Length);i++)
        {
            WinInetInterop.SetConnectionProxy(ipaddress[i]);
            label1.Text = ipaddress[i];
            webBrowser1.Url = new Uri(textBox1.Text);
        } 
    }

I want to launch website for all proxies.

pstrjds
  • 16,840
  • 6
  • 52
  • 61
  • are you sure the ip addresses are splited with new line in TextBox2? – Jonathan Applebaum Dec 24 '17 at 19:15
  • yes.it is , may i show it as screenshot – Brian Thomas Dec 24 '17 at 19:16
  • you can add a screenshot but more important, show us the part of the code that you implement`WinInetInterop`, also i think it needs a port number not only ip: `WinInetInterop.SetConnectionProxy(“192.168.10.1:8080”);` – Jonathan Applebaum Dec 24 '17 at 19:25
  • yes. there is a big setproxy file... yes i set it as you mentioned with port numebrs... I think the problem is in the for loop. can you suggest me a method to not to overwrite ? – Brian Thomas Dec 24 '17 at 19:37
  • the for loop looks ok, when you debug your code, put a breakpoint after `string[] ipaddress` is initialized, what is the length of the array? – Jonathan Applebaum Dec 24 '17 at 19:43
  • friend length is different. if we add 50 proxies . length will be 50... – Brian Thomas Dec 24 '17 at 20:22
  • Is this WinForms or WPF? In WinForms you can use the [Lines](https://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.lines(v=vs.110).aspx) property to get the lines. Also, no need to `Convert` the length, you can just use the length in your for loop. Also, when you say you want to `launch websites for all proxies`, how many web browser controllers do you have. In your sample you are setting the URL on the same controller, so each loop iteration is setting a new URL which is causing the browser control to navigate to the new one and thus only shows the last one. – pstrjds Dec 25 '17 at 06:30
  • can you set this to show website for all proxies ? – Brian Thomas Dec 25 '17 at 11:31
  • Are you saying you want to show all 50 sites at the same time? You would need 50 controllers. You can only navigate to one site at a time with the controller. What are you actually trying to achieve? – pstrjds Dec 25 '17 at 15:07
  • 50 is just a example..Amount of proxies are not same always – Brian Thomas Dec 25 '17 at 16:54
  • You still haven't answered if this is WinForms or WPF, but also, what is your goal? – pstrjds Dec 25 '17 at 17:13
  • this is a windowsform application – Brian Thomas Dec 25 '17 at 18:34
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/161940/discussion-between-pstrjds-and-brian-thomas). – pstrjds Dec 25 '17 at 20:31
  • You instruct that Webbrowser to visit 50 URLs in ~ 1µs. Why do you think it should not only display the last website it was instructed to browse to? If you want the 50 URLs to be downloaded, then wait for each URL until the download is complete. – Thomas Weller Dec 26 '17 at 21:02
  • Possible duplicate of [C# how to wait for a webpage to finish loading before continuing](https://stackoverflow.com/questions/583897/c-sharp-how-to-wait-for-a-webpage-to-finish-loading-before-continuing) – Thomas Weller Dec 26 '17 at 21:03

0 Answers0