Configure proxy for .NET 4.x apps


Here’s how to configure proxy settings for your .NET 4.x app.

When you start the Microsoft 365 Developer Proxy on Windows, it just works. It automatically registers itself as a system proxy on your machine and intercepts web requests for the URLs specified in its configuration. However, if you start an app built with .NET 4.x, you’ll see that the proxy is not picking up any of the app’s requests.

Microsoft 365 Developer Proxy not picking up requests from a .NET 4.x app

It turns out, that .NET 4.x uses WinHTTP API to implement proxy configuration. To configure a proxy so that it’s being used by .NET 4.x apps, you can use the netsh tool. For example, to enable a proxy running locally on port 8000, you’d use:

netsh winhttp set proxy proxy-server="http=localhost:8000;https=localhost:8000"

The netsh command to register a local proxy with the WinHTTP API in Windows Terminal

After running this command, if you restart your .NET 4.x app, you’ll see its requests intercepted by the proxy as expected.

Microsoft 365 Developer Proxy picking up requests from a .NET 4.x app

To disable the proxy, reset the configuration using:

netsh winhttp reset proxy
Others found also helpful: