I had a need to grab a pdf file provided by an internal server and send it back to a user of an external web site.
System.Net.WebClient has a method called DownloadData that makes this very easy. Here's an example:
string sURL = "
http://10.10.1.1/test/a.aspx?custid=254299;
System.Net.WebClient wc = new System.Net.WebClient();
byte [] bBuffer = wc.DownloadData(sURL);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(bBuffer);
Response.Flush();
Response.Close();
posted on Saturday, October 29, 2005 11:54 AM