2

I am working on a project to download files using .Net c# 2.0 SP1. One of the requirements of the project is to not seek any proxy details and automatically detect this from IE etc.

Now i haven't worked with proxy before and hence i am a bit baffled. After hours of searching google, msdn etc, i have come across the following article http://msdn.microsoft.com/en-gb/magazine/cc300743.aspx#S3

Now i am totally confused how to do this? Can someone please help me with an easier implementation or guide me please?

Sorry once again if i sound silly, but i haven't worked with .Net proxies and hence I am struggling.

This is for C# Winforms and hence i cannot do this in web.config.

Thanks in advance for your help.

Manish
  • 23
  • 4

1 Answers1

1

.NET 2.0 will automatically using the proxy settings from IE by default; however, there is an extra configuration step required to use the default proxy credentials saved in IE. To enable this, ensure that the following section appears in your app.config file:

<configuration>
    <!-- ... -->
    <system.net>
        <defaultProxy useDefaultCredentials="true"/>
    </system.net>

For a full description of the element, see MSDN. For more complicated HTTP Proxy scenarios, see Using HTTP Proxy Servers.

Bradley Grainger
  • 27,458
  • 4
  • 91
  • 108
  • I should have mentioned this that i need to do this for winforms. – Manish Feb 10 '10 at 15:47
  • I am looking for some C# code possible similar to C code here http://stackoverflow.com/questions/202547/how-do-i-find-out-the-browsers-proxy-settings/2238761#2238761 – Manish Feb 10 '10 at 17:07
  • @Manish haven't tested it yet but maybe this might help: "pac file should have proper content type (`Content-type: application/x-ns-proxy-autoconfig`)", more [Using Proxy Automatic Configuration from IE Settings in .Net](http://stackoverflow.com/a/13562345/1027198). – Michał Powaga Apr 29 '13 at 10:57