asp.net-mvc-4 – 如何在MVC4中呈现远程ReportViewer aspx页面?
|
我正在研究一个需要使用ReportViewer从SSRS渲染远程报告的MVC4应用程序.在这个论坛的帮助下,我设法让页面在MVC下呈现,但回调不起作用(加载初始页面).导出报告工作正常(并提供所有页面).当我检查页面时,我在更改页面后发现以下错误:
我在结合MVC和Web窗体时找到了this article,但由于没有更多的主布局页面,它看起来已经过时了.这与How can I use a reportviewer control in an asp.net mvc 3 razor view?有关但不重复,因为该文章仅适用于本地报告.我已经尝试将AsyncRendering更改为true和false.如果为true,则根本不加载.任何建议将不胜感激. 更新:以前版本的Visual Studio之间的AsyncRendering行为appears to have changed. 解决方法最后,由于不可接受的安全风险,我最终不得不放弃原来的答案和回调标准.在我的例子中,我编写了控制器代码,将报表呈现为HTML到字节数组,然后从那里到FileContentResult,MVC非常友好地呈现为静态HTML页面.通过将Render参数从HTML4.0更改为适当的(PDF,XLS)和MIME类型,最终将以类似的方式实现导出为PDF,Excel或任何其他选项.此方法适用于SQL Server 2008R2及更高版本.我没有尝试使用以前版本的SQL Server.[OutputCache(Duration = 120,VaryByParam = "id")]
public ActionResult ExportHTML(int id)
{
// we need to add code to check the user's access to the preliminary report.
// Also need to consolidate code between ExportHTML and ExportPDF.
var userid = <userid>;
var password = <password>;
var domain = <domain>;
IReportServerCredentials irsc = new myApp.Models.CustomReportCredentials(userid,password,domain);
var parametersCollection = new List<ReportParameter>();
parametersCollection.Add(new ReportParameter("Snapshot",id.ToString(),false));
ReportViewer rv = new Microsoft.Reporting.WebForms.ReportViewer();
rv.ProcessingMode = ProcessingMode.Remote;
rv.ServerReport.ReportServerCredentials = irsc;
rv.ServerReport.ReportPath = <reportpath>;
rv.ServerReport.ReportServerUrl = new Uri("http://localhost/ReportServer");
rv.ServerReport.SetParameters(parametersCollection);
rv.ServerReport.Refresh();
byte[] streamBytes = null;
string mimeType = "";
string encoding = "";
string filenameExtension = "";
string[] streamids = null;
Warning[] warnings = null;
streamBytes = rv.ServerReport.Render("HTML4.0",null,out mimeType,out encoding,out filenameExtension,out stream ids,out warnings);
var HTMLReport = File(streamBytes,"text/html");
return HTMLReport;
} (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net-core-mvc – Html.AntiForgeryToken()仍然需要?
- 使用ASP.NET Web服务的jQuery AutoComplete(jQuery UI 1.8r
- .net – IAuthenticationFilter.OnAuthenticationChallenge
- ASP.NET MVC – 查看主页,如何设置标题?
- asp.net – 在project.json中排除文件夹
- iis – 如何通过预编译ASP.NET站点来确定性能改进?
- asp.net-mvc – ASP.NET MVC控制器的静态方法
- asp.net – Mysql中int(10)的最大大小是多少?
- ASP.NET URL验证
- asp.net-mvc – 用Moq Mocking HttpContextBase
- asp.net-mvc – System.Web.Mvc.ActionFilterAtt
- 在ASP.Net中获取会话ID
- asp.net – html脚本标签不使用类型javascript?
- asp.net-mvc – 在Html.ActionLink的linkText中使
- ASP.NET路由:令牌之间的字面子段和来自文字子段
- asp.net – 如何在Gridview中绑定DropDownList,而
- asp.net-mvc – 如何将行的模型从Kendo Grid传递
- 显示下载进度条的下载文件代码
- asp.net – InvalidOperationException:在程序集
- asp.net-mvc – 使用JWT实现的最小WebAPI2 OAuth
