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.