4

I'm starting to write some very simple web-apps in C# and occasionally I get exceptions about not having a proxy configured. I am in a work environment that has a rather strict proxy auto-configuration file (.pac -- Proxy Auto-Config).

Is there a way to tell C# to use that .pac file for proxy settings?

PerryC
  • 1,233
  • 2
  • 12
  • 28
  • I don't know you to use a specific .pac file, but had similar proxy problems a while ago. The solution I found was to tell my app to use the Windows default proxy settings (and credentials). That is, what your browser probably does. If that is sufficient, I'll post some code. – Micke Jun 30 '15 at 18:17
  • This might also help: http://stackoverflow.com/questions/17078894/get-ies-default-proxy-with-defaultwebproxy – Micke Jun 30 '15 at 18:30
  • I've had success by adding the ' ' code to the App.config file **in addition to** checking the "Automatically Detect Settings" box in IE under Tools->Internet Options->Connections->Lan Settings. Oddly enough, some days just checking the box in IE will solve the issue. Other days I need to add the system.net code to my App.config. That issue I still haven't figured out. – PerryC Jul 09 '15 at 15:22

1 Answers1

1

.NET can use the default proxy settings of the user running the code. It uses the same settings that are defined for IE. See this article: https://msdn.microsoft.com/en-us/library/dkwyc043%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

You should also see this SO post about MIME types for the PAC file: Using Proxy Automatic Configuration from IE Settings in .Net

Community
  • 1
  • 1
poprogrammer
  • 61
  • 1
  • 5