try
{
int _quarterId = 0;
if (id != null)
{
_quarterId = (int)id;
}
else
{
_quarterId = Utility.GetQuarterIdFromSession();
}
int _businessId = Utility.GetBusinessIdFromSession();
if (_quarterId > 0 && _businessId > 0)
{
Return _return = _engineService.GetFormPdf(_quarterId, _businessId);
if (_return != null && _return.FormPDF != null &&
_return.FormPDF.Length > 0)
{
Response.Clear();
Response.Buffer = false;
Response.AddHeader("Accept-Header", _return.FormPDF.Length.ToString());
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename= FormPdf.pdf");
Response.AddHeader("content-length", _return.FormPDF.Length.ToString());
Response.BinaryWrite(_return.FormPDF);
Response.Flush();
}
}
}
catch (ThreadAbortException)
{
}
//This sets empty content and avoids the exception in changing the HTTP header
return new EmptyResult();
}
Asked
Active
Viewed 1,365 times
0

Vijay Sirigiri
- 4,653
- 29
- 31

yogeswaran K
- 2,278
- 8
- 29
- 45
-
And more importantly, provide some info regarding where and when the exception occurs, what has been done to diagnose the situation. – Anton Feb 15 '11 at 07:29
-
it occurs when viewing pdf file – yogeswaran K Feb 15 '11 at 07:54
-
Your action is flawed. You should return a FileResult. – erikkallen Feb 15 '11 at 12:09