Webclient w/ Proxy

S

Steven J. Reed

I have a WebClient.OpenRead that is timing out on some client machines. I
believe the problem may be Proxy settings on the client machine.

How do I set proxy settings on a WebClient.OpenRead method?
 
K

Ken Cox [Microsoft MVP]

Hi Steven,

Someone else may be able to help more with this, but it looks like you first
need to create a WebProxy object and use the GlobalProxySelection Class

How To Use WebClient Class To Make HTTP Requests

http://support.microsoft.com/default.aspx?scid=kb;en-us;328820#XSLTH3129121122120121120120


http://msdn.microsoft.com/library/d...ref/html/frlrfsystemnetwebproxyclasstopic.asp


private bool SetProxy(string ProxyName)
{
//Set the proxy
proxyObject = new WebProxy(ProxyName, true); // the true is to bypass
local address
// You can get the nondynamic proxy settings from Internet Explorer 5.5.
// by using the line below. This is what we use by default if you don't
set anything.
//WebProxy proxyObject = WebProxy.GetDefaultProxy();
// set the Credentials to the user's system credentials
// This will handle NTLM authentication.
// We will error trap for basic and then reqeust the username a password
proxyObject.Credentials = CredentialCache.DefaultCredentials;
GlobalProxySelection.Select = proxyObject;
return true;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top