suppose I want to automatically download a file from url that is located inside an authentication-required website into which I login using automated WebBrowser control based on Internet Explorer. But, once I am there and grab the link to the file, if I try to download it directly via IE6 by navigating to it, there will be the "do you want to open or save this file" modal dialog. And if I try to download it using C# WebClient class, it didn't work out, all that got downloaded was a short piece of non-meaningful javascript. In fact, out of curiosity I tested the WebClient method inside Gmail website trying to download attachments, and it didn't work either (I know that from Gmail I can grab them via POP3 interface, it was just an experiment).
Well, so this makes me wonder about the underlying mechanics of it all. First of all, maybe I am using WebClient in the wrong way? Or maybe there is some other standard C# class for downloading files in such circumstances?
If not, is it possible for the app to spoof the behavior of the browser so that the server would think that the request for file came from it, even though it actually comes from another part of the same process? What exactly is the browser doing in this situation that lets it download the files while WebClient cannot do so?