Configuring Internet Applications
Theconfiguration element contains network configuration information for applications. Using the element, you can set proxy servers, set connection management parameters, and include custom authentication and request modules in your application.
The HttpWebRequest that does not have its own Proxy property set to a specific value uses the default proxy. In addition to setting the proxy address, you can create a list of server addresses that will not use the proxy, and you can indicate that the proxy should not be used for local addresses.element defines the proxy server returned by the GlobalProxySelection class. Any
It is important to note that the Microsoft Internet Explorer settings are combined with the configuration settings, with the latter taking precedence.
The following example sets the default proxy server address to http://proxyserver, indicates that the proxy should not be used for local addresses, and specifies that all requests to servers located in the contoso.com domain should bypass the proxy.
<configuration> <system.net> <defaultProxy> <proxy usesystemdefault = "false" proxyaddress = "http://proxyserver:80" bypassonlocal = "true" /> <bypasslist> <add address="http://[a-z]+\.contoso\.com/" /> </bypasslist> </defaultProxy> </system.net> </configuration>
Use theelement to configure the number of persistent connections that can be made to a specific server or to all other servers. The following example configures the application to use two persistent connections to the server www.contoso.com, four persistent connections to the server with the IP address 192.168.1.2, and one persistent connection to all other servers.
<configuration> <system.net> <connectionManagement> <add address="http://www.contoso.com" maxconnection="2" /> <add address="192.168.1.2" maxconnection="4" /> <add address="*" maxconnection="1" /> </connectionManagement> </system.net> </configuration>
Custom authentication modules are configured with the IAuthenticationModule interface.element. Custom authentication modules must implement the
The following example configures a custom authentication module.
<configuration> <system.net> <authenticationModules> <add type="MyAuthModule, MyAuthModule.dll" /> </authenticationModules> </system.net> </configuration>
You can use the IWebRequestCreate interface. You can override the default HTTP, HTTPS, and file request modules by specifying your custom module in the configuration file, as in the following example.element to configure your application to use custom protocol-specific modules to request information from Internet resources. The specified modules must implement the
<configuration> <system.net> <webRequestModules> <add prefix="HTTP" type = "MyHttpRequest.dll, MyHttpRequestCreator" /> </webRequestModules> </system.net> </configuration>