我正在按照this指南在MVC应用程序中显示报告。它工作正常,我设法显示一些东西,问题是它显示的是ReportServer门户,而不是我想要显示的当前报告:
我一直在努力将其指向特定的报告,但始终打开该报告,我不知道自己在做什么错。
首先,我列出带有报告的页面,单击链接,然后调用aspx.cs。
列表页面如下:
@{
ViewBag.Title = "Index";
}
<h2>Reports List</h2>
<a id="ReportUrl_Performance" href="@Url.Action("ReportTemplate", "Report", new { ReportName = "ClientTest", ReportDescription = "Client Report", Width = 100, Height = 650 })">
Client Report
</a>
在这里,我们获得了想要的ReportName= "ClientTest"
报告的名称,然后重定向到另一个名为“ Report”的控制器,该控制器的操作为ReportTemplate,如下所示:
public ActionResult ReportTemplate(string ReportName, string ReportDescription, int Width, int Height)
{
var rptInfo = new ReportInfo
{
ReportName = ReportName,
ReportDescription = ReportDescription,
ReportURL = String.Format("../../Reports/ReportTemplate.aspx?ReportName={0}&Height={1}", ReportName, Height),
Width = Width,
Height = Height
};
return View(rptInfo);
}
这将打开存储ReportTemplate.aspx的路径。它的代码与指南中的相同,并且aspx.cs如下:
public partial class ReportTemplate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
String reportFolder = System.Configuration.ConfigurationManager.AppSettings["SSRSReportsFolder"].ToString();
rvSiteMapping.Height = Unit.Pixel(Convert.ToInt32(Request["Height"]) - 58);
rvSiteMapping.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
rvSiteMapping.ServerReport.ReportServerUrl = new Uri("http://lonl1564/ReportServer"); // Add the Reporting Server URL
rvSiteMapping.ServerReport.ReportPath = String.Format("/{0}/{1}", reportFolder, Request["ReportName"].ToString());
rvSiteMapping.ServerReport.Refresh();
}
catch
{
}
}
}
}
AppSettings["SSRSReportsFolder"]
在Web.config文件中设置为“ / Clients”。我尝试将URI设置为ReportServer和Webportal,并且仍然相同。
报告名称为“ ClientTest”,我将其作为视图中的参数发送:
这就是我要呈现报告的方式(操作:ReportTemplate,控制器:Report)
@model EvaluateWeb.Models.ReportInfo
<H1>
@Model.ReportDescription
</H1>
<iframe id="frmReport" src="@Model.ReportURL" frameborder="0" style="@String.Format("width:{0}%; height: {1}px;", Model.Width, Model.Height)" scrolling="no"></iframe>
单击链接时MVC应用程序正在生成的链接: -http://localhost/report/reporttemplate?ReportName=ClientTest&ReportDescription=Client%20Report&Width=100&Height=650
当我单击报告时,ReportServer打开的链接: -http://lonl1564/ReportServer/Pages/ReportViewer.aspx?%2fEvaluate%2fClientTest&rs:Command=Render
打开报告时,打开报告门户的链接: -http://lonl1564/Reports/report/Clients/ClientTest
在报告控制器中的URI和文件夹路径中应该放置什么正确的链接?如何设置打开的页面直接是“ ClientTest”报告,而不是包含文件夹的门户?
非常感谢,
亚历杭罗(Alejanro)