Challenge

  • Recently we have implemented functionality to export PDF from ASP.Net Web Application
  • We don’t want to render report in Report Viewer we only want to export PDF
  • When we deployed the application on Azure VM ( IaaS ) then everything was working fine
  • However when we have published the application on Azure Web App ( PaaS ) we are getting exceptions and issues
  • Please refer following code for reference ( which we have used to export PDF )

//list testReportModel
List<TestReportModel> testReportModel = GetReportData();

//get report bytes
Byte[] reportBytes = Common.GetReportByte(“~/Report/TestReport.rdlc”, testReportModel, “dsTestReport”, “PDF”);

//instantiate memory steram
MemoryStream reportStream = new MemoryStream(reportBytes);
reportStream.Seek(0, SeekOrigin.Begin);

Response.Buffer = true;
Response.ContentType = “application/pdf”;
Response.AddHeader(“content-disposition”, “attachment; filename=TestReport.pdf”);
Response.BinaryWrite(reportBytes);
Response.Flush(); // send it to the client to download
Response.Clear();

Solution

  • Please verify that following report viewer dll assemblies has copy local true in your solution explorer as follows

  • In your deployment package in bin folder please make sure you have following dll assemblies

  • If you want to use ReportViewer control then there is no support to render in Azure Web App then you have to either use Azure Web Role or Azure VM

Hope this helps