dotnet123123
❔ .NET background service - use windows OS level proxy
So, I have a background service written in C#/.NET running on windows 10 & 11. It does periodic http requests using the standard HttpClient.
The issue is that I need the HttpClient to use the Windows OS system wide proxy settings for the http requests. The issue is that as far as I can tell, the proxy settings can only be programmatically retrieved in the Registry under the "Current User" area. This can not be retrieved on the windows service because it runs under a different user than who is logged in.
Setting the proxy value in "Settings" GUI app, or using
netsh winhttp set proxy
, my background service http client traffic doesn't get routed through the proxy.
Any help would be greatly appreciated.
EDIT : stated another way. From a background service, how can I read the windows proxy settings successfully?8 replies