problem with WebClient

G

Guest

In an ASP.NET application I have to perform a file downloading task
from a web server not exposed to internet, ie
Internet Client-->MyServer-->SecureServer-->MyServer--> Internet Client

All works fine when I have to download a pdf or an image file but when I try
to access a zip file I obtain a 401 error ( unauthorized access )

The code I use is:

string uri = "http://SecureServer/TestSolution/Test.zip";
string fileName = "C:\\MyServer\\ClientFile.zip";

WebClient wc = new WebClient();
wc.Credentials = CredentialCache.DefaultCredentials;
wc.DownloadFile(weburi, fileName);

Any help would be appreciated,
Thanks in advance
 
J

Joerg Jooss

Thus wrote gianniab,
In an ASP.NET application I have to perform a file downloading task
from a web server not exposed to internet, ie
Internet Client-->MyServer-->SecureServer-->MyServer--> Internet
Client
All works fine when I have to download a pdf or an image file but when
I try to access a zip file I obtain a 401 error ( unauthorized access
)

The code I use is:

string uri = "http://SecureServer/TestSolution/Test.zip"; string
fileName = "C:\\MyServer\\ClientFile.zip";

WebClient wc = new WebClient();
wc.Credentials = CredentialCache.DefaultCredentials;
wc.DownloadFile(weburi, fileName);

How is that server secured? Is it in your Intranet or on the Internet?

Cheers,
 
G

Guest

The secure server is on the intranet, while the web server is exposed to
internet, but i have the same problem also in a simplified development
environment with the zip file in the same directory as the web application
 
J

Joerg Jooss

Thus wrote gianniab,
The secure server is on the intranet, while the web server is exposed
to internet, but i have the same problem also in a simplified
development environment with the zip file in the same directory as the
web application

OK. I was wondering whether passing CredentialCache.DefaultCredentials has
any effect here. Are you sure you must authenticate like that? Is there a
web application that controls access to these ZIP files?

If you can download these files with your browser, you might want to use
Fiddler to capture the HTTP traffic and compare your "coded" session with
an interactive session.

Cheers,
 
G

Guest

Joerg Jooss said:
OK. I was wondering whether passing CredentialCache.DefaultCredentials has
any effect here. Are you sure you must authenticate like that? Is there a
web application that controls access to these ZIP files?

The point is that i don't have to authenticate at all, using the Credential
is an attempt due to the 401 error for the zip files(all works in the right
way with the same code with gif, jpg, tiff or pdf files ); in production i
have an aspx page with a button that calls an asp page on the secure server
the return the files as a stream...
If you can download these files with your browser, you might want to use
Fiddler to capture the HTTP traffic and compare your "coded" session with
an interactive session.

ok, that's an idea
Thanks
Gianni
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top