Good Day Everyone I have a response which i convert to byte array and download the pdf at the end. This code does download a PDF in localhost but gives an error {"Thread was being aborted."} and the file still get downloaded correctly. The code is defined as below
string URL = "http://myserver/ReportServer/Pages/ReportViewer.aspx?%2Fbills%2FISU\_PDF\_GEN\_APT&rs:Command=Render";
string Command = "Render";
string Format = "PDF";
//We can get values of these parameters from Request object.
string Contract_account_number = AccountNumber;
URL = URL + "&rs:Command=" + Command + "&rs:Format=" + Format + "&Contract_Account_Number=" + Contract_account_number;
System.Net.HttpWebRequest Req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(URL);
Req.Credentials = System.Net.CredentialCache.DefaultCredentials;
Req.UseDefaultCredentials = true;
Req.Method = "GET";
System.Net.WebResponse objResponse = Req.GetResponse();
System.IO.Stream stream = objResponse.GetResponseStream();
var document = GenericMethods.StreamToByteArray(stream);
Response.AddHeader("Content-type", "application/octet-stream");
Response.AddHeader("Content-Disposition", "attachment; filename=" + AccountNumber + ".pdf");
Response.BinaryWrite(document);
Response.Flush();
Response.End();
when i host this in IIS i get an Error The remote server returned an error: (403) Forbidden. Thanks
Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vimalsoft.com vuyiswa[at]vimalsoft.com