Home Datacenter Configuring system-wide proxy for .NET web applications, including SharePoint

Configuring system-wide proxy for .NET web applications, including SharePoint

by Philip Sellers

Several years ago, I wrote about setting proxy settings to enable the SharePoint App Store to work when running behind a web proxy and about resolving it when running HTTPS/SSL. Today, I want to revisit that solution since we found problems with it in the enterprise setting.  The solution I found originally was to configure web.config on each of the SharePoint virtual sites in IIS, but there is an easier way and one that is more flexible.  SharePoint, by design, creates many virtual sites automatically so manually configuring each web.config is cumbersome and not a great solution.

Instead, .NET 4 is able to use the system proxy settings, which allows the administrator to set (and change) the proxy settings by group policy or manually on the SharePoint web servers.  This is preferable and more maintainable than setting manual settings on each IIS virtual site using the web.config file.  Since you have set these in the default .NET web.config files, you don’t need to change newly generated web.config files for each new site you create in SharePoint.  That becomes painful quickly in an enterprise setting with multiple web front-end servers and multiple sites.  It is also easy to miss one here or there.

This method also works with any .NET web application running on a Windows system, so it applies beyond just SharePoint.

Configuring the default .NET proxy settings

To set the default .NET proxy settings, you will need to edit the web.config file in the .NET Framework folders, located at these two paths:

  • C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config
  • C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config

In the web.config file, you will need to set the defaultproxy settings as shown below.

[code]<system.net>
<defaultProxy>
<proxy usesystemdefault="true" />
</defaultProxy>
</system.net>[/code]

Once this is set and you restart your web services, they should now inherit and use the system default proxy settings.

The next step is to ensure you have the correct proxy settings configured on the host.  You may inspect the current settings using netsh:

[code]netsh winhttp show proxy[/code]

If correct, there is nothing else to do.  If you have a group policy that sets the proxy settings, you may already have them correctly configured.

If you need to change them, you will use netsh again:

[code]netsh winhttp set proxy proxyserver:8080[/code]

For the full specifics of the netsh proxy commands, you may refer to this TechNet article.  You may need to set a bypass list of internal sites in addition to the proxy server and port number.

 

You may also like