Tutorial :How to make .NET application access internet through proxy



Question:

I have a dll which will retrieve certain information from internet. I'm calling this dll from my wrapper application. But the dll cannot access internet because it behind corporate proxy. Is there any way by which I can so authentication in the wrapper application, (eg by providing an interface to enter proxy username and password), so that the dll can access internet.

EDITED:: I'm accessing Google Data API dll which accepts username and password to login.


Solution:1

Do you control the code within the DLL? How does the DLL request the information? .NET certainly has proxy handling for things like WebClient and HttpWebRequest, but you'll need to give more information about the situation.

EDIT: Unfortunately I can't see anything in the GData API which exposes a proxy property.

You could try just setting the default proxy using GlobalProxySelection.Select. If that doesn't work, let me know and I'll try asking for suggestions internally.


Solution:2

You can assign the Proxy property of your WebRequest or WebClient object to a WebProxy object that has the required settings applied. It basically works as follows:

WebRequest request = WebRequest.Create("http://www.mysite.com");   request.Proxy = new WebProxy("127.0.0.1", 8080);   

You can also assign a username/password using the Credentials property of the WebProxy.

See the examples associated with the WebProxy class on MSDN.


Solution:3

The GDATA Api uses your Global IE proxy, try setting your IE global proxy using the required registry keys from your wrapper application, GData api will pick it up automatically.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »