System.Net.CredentialCache.DefaultCredentials are blank

  • Thread starter Thread starter Steve Ng
  • Start date Start date
S

Steve Ng

Hello,

I have a windows form application that needs to pass through a proxy
to get access to the internet. As a test, I have successfully
hardcoded my login/password/domain combination and been able to gain
access through the proxy.

I would like to ditch the hardcoded login/password/domain combination
and use the settings defined in Internet Explorer. I've read that I
can use System.Net.CredentialCache.DefaultCredentials to get the
credentials of the machine that the application is running from. When
I try this, all the fields in DefaultCredentials are blank and of
course I get denied access through the proxy.

Any clues to what I'm doing wrong or what would cause the
DefaultCredentials to be blank? I've duplicated the behaviour on two
machines, both running XP SP1. Here's an excerpt of my code ...


// code is quite simple and in this example, I've tried to assign
DefaultCredentials to the proxy object and the Web Service.

RService rs = new RService();

WebProxy proxyObject = new WebProxy("http://proxyaddress:port");
proxyObject.Credentials =
System.Net.CredentialCache.DefaultCredentials;

bool success = false;
string message = string.Empty;

try
{
rs.Proxy = proxyObject;
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
success = rs.IsReachable();
}
catch (SoapException soapEx)
{
message = soapEx.ToString();
}
catch (Exception ex)
{
message = ex.ToString();
}


Any help would be appreciated. Thanks!

Steve
 
Back
Top