views:

38

answers:

2

Hi all,

I need to get the binary data of a download link.

When I run this link in the browser it always starts download manager. Rather I would like to copy that binary and display it on teh browser. How is this possible in any language.

Objective c or c# preferred.

Thanks

A: 

Using the WebClient class you could perform an HTTP request to a given url and retrieve the result:

using (var client = new WebClient())
{
    byte[] data = client.DownloadData("http://example.com/foo");
    // Do something with the binary data
}
Darin Dimitrov
A: 

What are you trying to download? For example, to display a PDF directly to the browser you can do something like this:

var data = HoweverYouAreLoadingYourByteArray();
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=MyFile.pdf");
Response.BinaryWrite(data);
Response.Flush();
Response.Close();

Just make sure you are setting the correct content type for whatever type of binary file you are trying to push to the browser.

jaltiere