0
我在过去两天中遇到了问题。我正在尝试将rdlc报告视为没有reportviewer的pdf。我RDLC导出到使用下面的代码的PDF ...在Asp.net MVC中查看RDLC报告为pdf
public string Export(LocalReport rpt, string filePath)
{
string ack = "";
try
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
byte[] bytes = rpt.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);
using (FileStream stream = File.OpenWrite(filePath))
{
stream.Write(bytes, 0, bytes.Length);
}
return ack;
}
catch(Exception ex)
{
ack = ex.InnerException.Message;
return ack;
}
}
出口到用户 - > AppData- PDF文件>临时
string filePath = System.IO.Path.GetTempFileName();
string ack = Export(rpt, Server.MapPath("~/Reports/Mymun_Lab/ComparisonStudy.rdlc"));
System.Diagnostics.Process.Start(filePath);
我想使这个PDF文件到客户端PC。
此代码在我的本地计算机上工作正常。但是,当我发布到IIS服务器并运行尝试获取导出的PDF文件到客户端PC不成功。我该如何解决这个问题。谁能帮我。
在此先感谢...
是这还工作吗? –
我得到返回文件(filePath,“application/pdf”) –
在哪里添加Export()方法?直接在控制器或单独的类?您是否在您的项目参考中添加了适当版本的Microsoft.ReportViewer.WebForms.dll? @ElbertJohnFelipe –