locked
Frame Control and Proxy Authentication RRS feed

  • Question

  • I am using a System.Windows.Controls.Frame in a WPF application. I'm trying to use the Frame to display specific web pages outside of the company intranet which uses a proxy server. The proxy requires authentication.

    I have tried to configure WebRequest.DefaultWebProxy to use specified credentials for the proxy. Here's my current approach (assume a Frame control named 'frame' has already been declared):

    Code Block

                WebProxy proxy = new WebProxy("proxyURI");
                proxy.BypassProxyOnLocal = true;
               

                NetworkCredential credentials = new NetworkCredential("username", "password");


                WebRequest.DefaultWebProxy = proxy;
                WebRequest.DefaultWebProxy.Credentials = credentials;
               
                frame.Source = new Uri(new Uri("basePath"),"relativePath");


    I have two issues.


    1. I can't get the block of code above to reliably succeed. Sometimes I get a WebException (407) indicating that Proxy Authentication is required. The rest of the time, I get the Internet Explorer dialog box pop-up that asks me to input/confirm my username and password for the proxy server, and after I do so, the frame displays the correct page. I am not sure what would be causing it to work intermittently. Currently, it's working 100% of the time. If I come back to it in a few hours, it may not work at all. I feel like if I connect to the internet via Internet Explorer shortly before I try to execute the code, the success rate is higher (fluke?).
    2. Assuming #1 is solved, is there anyway I can prevent the proxy authentication dialog from popping up each time this block of code is run? I want to specify the credentials "under the hood" so that users do not need to confirm each time, but it seems that even passing in a username/password still causes the dialog to appear.
    Thanks in advance for any help.
    Wednesday, January 16, 2008 12:55 AM

All replies

  • assuming #1 is solved, you can solve #2 by adding the site to your Trusted Sites under IE.
    Friday, January 18, 2008 7:59 PM