Hi nrcaliendo,
Thank you for posting here.
For your question, PreAuthenticate could not cache credentials set on the Proxy.Credentials property of proxy objects.
PreAuthenticate and Uri are bound.
After a client request to a specific
Uri is successfully authenticated, if
PreAuthenticate is true and credentials are supplied, the Authorization header is sent with each request to any
Uri that matches the specific
Uri up to the last forward slash. However the proxy could not do that.
For more details about HttpWebRequest.PreAuthenticate Property, please refer to the
link.
PreAuthenticate won’t cache the proxy’s credential. So the workaround maybe:
- Using defaultcredential for his proxy.
- Hard code credential in his code when initializing his proxy.
Here is an example about Proxy Authentication.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
IWebProxy proxy = request.Proxy;
if (proxy != null)
{
Console.WriteLine("Proxy: {0}", proxy.GetProxy(request.RequestUri));
}
else
{
Console.WriteLine("Proxy is null; no proxy will be used");
}
WebProxy myProxy = new WebProxy();
Uri newUri = new Uri("http://20.154.23.100:8888");
// Associate the newUri object to 'myProxy' object so that new myProxy settings can be set.
myProxy.Address = newUri;
// Create a NetworkCredential object and associate it with the
// Proxy property of request object.
myProxy.Credentials = new NetworkCredential("userName", "password");
request.Proxy = myProxy;
For more details about Proxy Authentication, please refer to the
link.
I hope this would be helpful to you.
If you have something else, please feel free to contact us.
Wendy
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.