C
cindy.fisher
I am using DownloadFile() on a C# web app to download a file to a
client. When I set the WebClient credentials to the DefaultCredentials,
I get a 401 Unauthorized exception.
WebClient myWC = new WebClient();
myWC.Credentials = CredentialCache.DefaultCredentials;
myWC.DownloadFile(myRemoteUri, myFile);
However, when I set the credentials using a username and password it
works.
myWC.Credentials = new Net.NetworkCredential("username","pwd");
Can someone please explain to me why I cannot use the default
credentials as I do when I'm calling a web service.
MyWS proxy = new MyWS();
proxy.Credentials = CredentialCache.DefaultCredentials;
proxy.CallAMethod();
// this works!
I would expect the DefaultCredentials to work for the WebClient as well
since I have the credentials in cache (from the user login to get to
the page). The web site is configured for Integrated Windows
authentication. The form pages use basic authentication, and the web
services use Integrated Windows (so we can pass the credentials).
Thanks,
Cindy
client. When I set the WebClient credentials to the DefaultCredentials,
I get a 401 Unauthorized exception.
WebClient myWC = new WebClient();
myWC.Credentials = CredentialCache.DefaultCredentials;
myWC.DownloadFile(myRemoteUri, myFile);
However, when I set the credentials using a username and password it
works.
myWC.Credentials = new Net.NetworkCredential("username","pwd");
Can someone please explain to me why I cannot use the default
credentials as I do when I'm calling a web service.
MyWS proxy = new MyWS();
proxy.Credentials = CredentialCache.DefaultCredentials;
proxy.CallAMethod();
// this works!
I would expect the DefaultCredentials to work for the WebClient as well
since I have the credentials in cache (from the user login to get to
the page). The web site is configured for Integrated Windows
authentication. The form pages use basic authentication, and the web
services use Integrated Windows (so we can pass the credentials).
Thanks,
Cindy