class Program
{
static void Main(string[] args)
{
using (WebClient webClient = new WebClient())
{
string str = webClient.DownloadString(
"http://www.google.com");
Console.WriteLine(str);
}
}
}
Notice in the above sample there is no code whose purpose is to set up or configure a PAC file or proxy server. It all just works under the covers. The PAC file and/or proxy server can be set using “Auto proxy configuration settings for Internet Explorer.”
As an example of how a PAC File and Proxy can be set using “Auto proxy configuration settings for Internet Explorer” is as follows:
- Launch Internet Explorer
- Click on the gear icon in the upper right corner and select Internet options:
- Click on the Internet options menu item displays the Internet Options dialog. From the Internet Options dialog select the Connection tab (see below):
- On the Internet Options dialog, click on the LAN settings button which displays the Local Area Network (LAN) Settings dialog:
- The Local Area Network (LAN) Settings dialog is organized as follows:
- The group box at the top is entitled “Automatic configuration” and the purpose of this section is to assign a PAC File that can be used by the Windows (including .NET applications).
- The group box at the bottom is entitled, “Proxy server” and the purpose of this section is to assign a Proxy Server to be used by Windows (including .NET applications).
- To assign a PAC File that will be used by Windows applications configuration the Local Area Network (LAN) Settings dialog as follows:
- Note that in the screenshot above that
- The checkbox “Automatically detect settings” was checked so that applications will pickup the specific PAC File automatically.
- The checkbox “Use automatic configuration script” when checked enables a text box in which a PAC File (which is really a URL pointing to a file) can be specified.
- To assign a Proxy Server that will be used by Windows applications configuration the Local Area Network (LAN) Settings dialog as follows:
- Note that in the screenshot above that
- The checkbox “use a proxy server for your LAN” was checked so that applications will pickup the specific Proxy Server automatically.
- The text boxes below this check box allow the proxy server host and the port it listens on to be specified
- The checkbox “Bypass proxy server for local address” when checked enables a application to make calls against local host. Such calls are necessary, for example, when performing OAuth authentication against Google. A local browser (127.0.0.1) is used to retrieve the authentication code returned by Google.
No comments :
Post a Comment