locked
RDLC server side render report RRS feed

  • Question

  • User-1716951449 posted

    I have problem streaming the server-side rendered report content

                var rptVw = new ReportViewer();
    
                var rptLocal = rptVw.LocalReport;
                rptLocal...
                rptLocal.Refresh();
    
                // http://www.c-sharpcorner.com/blogs/rdlc-report-export-on-server
                string mimeType = null;
                string encodingName = null;
                string fileNmExt = null;
                string[] streams = null;
                Warning[] warnings = null;
                var output = rptLocal.Render("Word", null, out mimeType, out encodingName, out fileNmExt, out streams, out warnings);
    
                Encoding encoding = (encodingName == null) ? Encoding.Default : Encoding.GetEncoding(encodingName);
                var outputStr = encoding.GetString(output);
    
                if (!fileNmExt.StartsWith(".")) fileNmExt = "." + fileNmExt;
    
                var resp = Response;
                resp.Clear();
                resp.Buffer = true;
                resp.AddHeader("content-disposition", string.Format("attachment;filename={0}{1}", this.FileNameField, fileNmExt));
                //resp.Charset = "";
                resp.ContentType = mimeType; // "application/vnd.ms-word";
                resp.Write(outputStr);
                resp.Flush();
                resp.End();
    

    file downloaded, but garbage content is showing up at client side

    i'm suspecting using wrong encoding, but i dunno what encoding to be use.

    Monday, November 6, 2017 11:27 AM

Answers

  • User-1716951449 posted
                var output = rptLocal.Render("Word", null, out mimeType, out encodingName, out fileNmExt, out streams, out warnings);
                ...
                resp.BinaryWrite(output);
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 7, 2017 4:02 AM