Comma appended to filename of streamed file
-
I'm generating reports using Business Objects (aka Crystal Reports) XI release 2. I'm running ASP.NET 2.0. Here's the relevant code (C#):
CrystalDecisions.CrystalReports.Engine.ReportDocument rdReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); //Uses the full physical file path of the report file on the IIS server. rdReport.Load(strReportFilePath); //Sets the report's data source to the dataset just generated. rdReport.SetDataSource(dsReport); //Clear the current page Response.ClearContent(); Response.ClearHeaders(); //Output the crystal report in PDF format to the page. Response.ContentType = "application/pdf"; Response.AppendHeader("Content-disposition", "inline; filename=test.pdf" ); rdReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, false, "");
The problem is that that file generated is named "test.pdf," insead of "test.pdf". It doesn't matter what file format the export is (ie .doc, .xls, .pdf, .rtf, etc.), whether or not the extension is included, or whether the "test.pdf" is replaced by a variable. The system always appends a comma to the end of the file name. Any ideas? Thanks for your help! -
I'm generating reports using Business Objects (aka Crystal Reports) XI release 2. I'm running ASP.NET 2.0. Here's the relevant code (C#):
CrystalDecisions.CrystalReports.Engine.ReportDocument rdReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); //Uses the full physical file path of the report file on the IIS server. rdReport.Load(strReportFilePath); //Sets the report's data source to the dataset just generated. rdReport.SetDataSource(dsReport); //Clear the current page Response.ClearContent(); Response.ClearHeaders(); //Output the crystal report in PDF format to the page. Response.ContentType = "application/pdf"; Response.AppendHeader("Content-disposition", "inline; filename=test.pdf" ); rdReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, false, "");
The problem is that that file generated is named "test.pdf," insead of "test.pdf". It doesn't matter what file format the export is (ie .doc, .xls, .pdf, .rtf, etc.), whether or not the extension is included, or whether the "test.pdf" is replaced by a variable. The system always appends a comma to the end of the file name. Any ideas? Thanks for your help!Hi there, There are a couple of things that you might check to narrow the scope of your finding: + Do you call the
Response.End()
after data is sent to the output stream of the Response object? + Are you sure that you use theinline
parameter instead of theattachment
? + Does it work in the ASP.NET 1.1? + Have you tried to simply send the content of a file to the output stream of the Response object and see if you can get the correct file name at the client side?