Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,

Does anyone know how I can set up a system wide proxy in Windows 7 and XP?
I have a windows form project in C# that uses web service via internet.
in my system it works correctly. But in another system with proxy it doesn't connect to web service! Althogh the browsers in this system connect correctly.

The proxy requires authentication so each browser that needs to access the internet must have the username and password entered into it. This is fine for browsers, but my C# application can't access the internet .

I set this code in app.config of my project:
XML
<system.net>
    <defaultProxy useDefaultCredentials="true" />
  </system.net>


please help me.
Posted
Updated 18-Apr-15 20:03pm
v2

Obviously default credentials can't go through the proxy...
You have two options:
1. Add a DLL that does the authentication via module element: https://msdn.microsoft.com/en-us/library/6w93fssz(v=vs.110).aspx[^]...The DLL must contain a class implementing IWebProxy[^]

2. Do all the proxy from your code:
C#
WebProxy oWebProxy = new WebProxy("proxy-server-address", true);
oWebProxy.Credientials = new NetworkCredential("user-name", "password");

WebRequest oWebRequest = WebRequest.Create("address");
oWebRequest.Proxy = oWebProxy;

// do the rest of the request...
 
Share this answer
 
Comments
Zon-cpp 19-Apr-15 3:09am    
i don't have a 'web service' project! or a 'web client' with some web requests...

I have a 'Windows Form' project in C# that add web reference and I call functions of web service that is added.

But connection with web service has a problem via proxy with user and password.
Kornfeld Eliyahu Peter 19-Apr-15 3:12am    
In that case the only option you have is option 1...
Zon-cpp 19-Apr-15 3:28am    
ok, I 'll try it and tell you the result. Thank you.
can you get me a simple project that uses that Dll ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900