I am generating rdlc report in asp.net (visual studio 2010). Currently, using the following code, I am able to export the report to pdf format on a button click event. Response.Flush() in the end is prompting user to download it at the desired location.
What I want is,
1) Instead of generating a pdf on a button click, I want to export my report automatically to pdf after the report gets generated on a page load event
2) That pdf report should get saved automatically at the specified location on the web server instead of prompting user to download it on their PC.
Is this achievable?
protected void CreatePDF()
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
string savelocation = Server.MapPath("Registrations")+ "\\" + fileName;
// Setup the report viewer object and get the array of bytes
byte bytes = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
Response.Buffer = true;
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=" + fileName);