Download a file from the website using webclient or any other method

I am trying to download a file using a WebClient download file method.
But on one particular site the website requires to select a few button selections after the URL is entered.
How can I a download a file in this case

http://www.blackrock.com/ca/individual/en/products/239839/ishares-sptsx-capped-energy-index-etf/1402045142285.ajax?fileType=csv&fileName=XEG_holdings&dataType=fund

The above url if entered into a browser, requires to select the type of Investor and then hit the Enter site button to download the file

I am using the following code, which works fine for other websites where no user selection is needed.

WebClient webClient = new WebClient();      
 webClient.DownloadFile(downloadFile, downloadLocation);

// download file is the http URL
// downloaded location is some location on the local computer
LVL 1
countrymeisterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
Use Fiddler to see what is transmitted in this case and replay this using HttpClient.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ioannis ParaskevopoulosCommented:
Hi,

I have not tested and i do not know if it would break any of that site's rules, but one thing you could do is see what is the link presented in the button.

For instance i selected the option of being an individual investor. Then the button went green. Then i copied the link location (right click on the button) and got the location of the requested file. Maybe you could use this instead of the given url.

Giannis
countrymeisterAuthor Commented:
ste5an,

Thank you for letting me know about Fiddler. I was able to see the actual URL after I hit the buttons in fiddler
the URL value does not change in the browser.

Ark,

Thanks for the answer, it was correct what was important to me was how to get to the answer, not just the answer.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.