Search code examples
c#.nethttpwebrequesthttpwebresponsenetworkcredentials

Web browser proxy authentication


I have a computer that does not access the internet without a proxy and an authentication (username and password). So I did it:

var webProxy = new WebProxy(PROXY_ADRESS, PORT);
webProxy.Credentials = new NetworkCredential(USERNAME, PASSWORD, DOMAIN);
var webRequest = (HttpWebRequest)WebRequest.Create("https://www.google.com.br/");
webRequest.Proxy = webProxy;

HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
Stream receiveStream = response.GetResponseStream();

webBrowser1.DocumentStream = receiveStream;

When I execute this code, the web browser loads (with some scripts errors) the Google page, but it does not load some images and when I click in Search or any other button the page gets white with a text with the end of the URL, for example: /search.

How can I navigate to other pages and load the full page (including the images)?


Solution

  • I've followed this tutorial and now it's working:

    http://www.journeyintocode.com/2013/08/c-webbrowser-control-proxy.html