Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Configuring Internet Applications

The <system.net> Element (Network Settings) configuration element contains network configuration information for applications. Using the <system.net> Element (Network Settings) element, you can set proxy servers, set connection management parameters, and include custom authentication and request modules in your application.

The <defaultProxy> Element (Network Settings) element defines the proxy server returned by the GlobalProxySelection class. Any 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.

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.

                usesystemdefault = "false"
                proxyaddress = "http://proxyserver:80"
                bypassonlocal = "true"
                <add address="http://[a-z]+\.contoso\.com/" />

Use the <connectionManagement> Element (Network Settings) element 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, and one persistent connection to all other servers.

            <add address="http://www.contoso.com" maxconnection="2" />
            <add address="" maxconnection="4" />
            <add address="*" maxconnection="1" />

Custom authentication modules are configured with the <authenticationModules> Element (Network Settings) element. Custom authentication modules must implement the IAuthenticationModule interface.

The following example configures a custom authentication module.

            <add type="MyAuthModule, MyAuthModule.dll" />

You can use the <webRequestModules> Element (Network Settings) element to configure your application to use custom protocol-specific modules to request information from Internet resources. The specified modules must implement 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.

                type = "MyHttpRequest.dll, MyHttpRequestCreator"

Community Additions

© 2015 Microsoft