I work in a office which requires all connections to be made through a specific http proxy. I need to write a simple application to query some values from a webserver – it’s easy if there were no proxy. How can I make the C# application proxy-aware? How can I make any sort of connection through a proxy?
Share
This is easily achieved either programmatically, in your code, or declaratively in either the web.config or the app.config.
You can programmatically create a proxy like so:
You’re basically assigning the
WebProxyobject to therequestobject’sproxyproperty. Thisrequestwill then use theproxyyou define.To achieve the same thing declaratively, you can do the following:
within your web.config or app.config. This sets a default proxy that all http requests will use. Depending upon exactly what you need to achieve, you may or may not require some of the additional attributes of the defaultProxy / proxy element, so please refer to the documentation for those.