asp.net-mvc – 在MVC Action中将SSRS报告导出为PDF
发布时间:2020-05-22 12:00:38 所属栏目:asp.Net 来源:互联网
导读:是的,我想将SSRS报告导出到PDF并将其从我的操作中返回,我没有任何Report Viewer.请告诉我如何实现这一点.到目前为止我做到了这一点 public void SqlServerReport() { NetworkCredential nwc = new NetworkCredential(username, password, domain);
|
是的,我想将SSRS报告导出到PDF并将其从我的操作中返回,我没有任何Report Viewer.请告诉我如何实现这一点.到目前为止我做到了这一点 public void SqlServerReport()
{
NetworkCredential nwc = new NetworkCredential("username","password","domain");
WebClient client = new WebClient();
client.Credentials = nwc;
string reportURL = "http://servername/ReportServer/reportfolder/StateReport&rs:Command=Render&rs:Format=PDF";
Byte[] pageData = client.DownloadData(reportURL);
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition","attachment; filename=" + DateTime.Now);
Response.BinaryWrite(pageData);
Response.Flush();
Response.End();
}
上面的代码抛出异常 "The remote server returned an error: (401) Unauthorized." 我的问题是 解决方法我纠正了上面的代码,现在它的工作public ActionResult GetPdfReport()
{
NetworkCredential nwc = new NetworkCredential("username","password");
WebClient client = new WebClient();
client.Credentials = nwc;
string reportURL = "http://someIp/ReportServer/?%2fReportProjectName/ReportName&rs:Command=Render&rs:Format=PDF";
return File(client.DownloadData(reportURL),"application/pdf");
}
我没有找到任何其他替代方法来在不使用ReportViewer的情况下在MVC中导出SSRS报告. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – ASP.NET MVC路由和静态数据(即图像,脚本等)
- asp.net-mvc – 实现多租户ASP.NET MVC应用程序的最快方法
- asp.net-core – 什么应该是WEB API Action Method的返回类
- asp.net – Visual Studio和C#的竞争对手
- 用户登录时,ASP.NET Core更改EF连接字符串
- asp.net – 使用[WebMethod]转义的JSON响应
- asp.net-mvc – ASP.NET MVC – 什么是UrlRoutingModule?
- asp.net-mvc – 我可以从HttpContext获取控制器吗?
- asp.net-mvc – 避免“类或CssClass值未定义”ASP.NET MVC中
- asp.net-web-api – 将JSON数组从Javascript传递到Web API
推荐文章
站长推荐
热点阅读
