WebClient.DownloadFile() Fails!

  • Thread starter Thread starter Mark Olbert
  • Start date Start date
M

Mark Olbert

I am running into a problem debugging a Windows Forms application which downloads updates from an ASPNET2 website. The Forms
applicaiton is .NET v1.1

The problem is a security exception on the call to WebClient.DownloadFile() ("target machine actively refuses the connection...").
The site that I am trying to download from is an ASPNET2 website running on my local development machine, which is the same machine
where I am trying to debug the Forms application (I have the ASPNET2 website running while attempting the download. I know it's
reachable from the Forms app because a number of other webservices calls against it succeed).

My guess is that, for some amazingly stupid reason, the Forms app doesn't trust connections to a website running on the same machine
it's running on. Talk about paranoia!

If that's the case, how do I get the Forms app and the local website to play together? I tried adding http://localhost to my list of
trusted sites in IE (which seems really stupid, I admit), but that didn't solve the problem.

Suggestions are welcome and wanted!

- Mark
 
Hello Mark,

Can the file be downloaded in IE directly? For example, you may type the
url like "http://localhost/test/test.zip" in IE, can this file be
downloaded? If not, the problem should be with Server side, you may check
the IIS settings; If it can be download in IE, you can try to set the
Credentials property for your WebClient to see if it will help, for example:

WebClient.Credentials =System.Net.CredentialCache.DefaultCredentials;

Hope this help,

Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Luke,

I'll check, but I think you're missing a key part of the problem: this isn't IIS we're dealing with here. It's the embedded server
that runs when you debug a website under VS2005. I don't even have IIS installed on my development machine.

- Mark
 
In this senario, you may first run the web project in VS.NET 2005 (so the
embedded server is running), and then test in IE with port number
specified.

Please let us know what you find. Thanks.

Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top