DownloadFile and Credentials
- From: cindy.fisher@xxxxxxxxxxxxxxxxxx
- Date: 26 Aug 2005 15:32:02 -0700
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
.
- Follow-Ups:
- Re: DownloadFile and Credentials
- From: Nathan Sokalski
- Re: DownloadFile and Credentials
- Prev by Date: Re: This is brilliant! Just look how long it is! Ha ha ha ha ha ha
- Next by Date: Re: This is brilliant! Just look how long it is! Ha ha ha ha ha ha
- Previous by thread: Unable to get the project file from the web server
- Next by thread: Re: DownloadFile and Credentials
- Index(es):
Relevant Pages
|