我们的SSRS和报表查看器有问题。我们使用一个简单的aspx页面来显示我们的报告:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReportView.aspx.cs" Inherits="Estam.Web.ReportView" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body style="margin: 0">
<form id="form1" runat="server">
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
ProcessingMode="Remote" Width="100%" SizeToReportContent="true" ZoomPercent="100"
ShowCredentialPrompts="False" ShowParameterPrompts="False" AsyncRendering="False">
<ServerReport />
</rsweb:ReportViewer>
</form>
</body>
</html>
using System;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Security.Principal;
using System.Web.UI;
using Microsoft.Reporting.WebForms;
namespace Estam.Web
{
public partial class ReportView : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(IsPostBack) return;
ReportViewer1.ServerReport.ReportServerCredentials = new EstamReportServerCredentials();
ReportViewer1.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServerUrl"]);
ReportViewer1.ServerReport.ReportPath = "/tierviewnet/Reports/" + Request.QueryString["report_name"];
ReportViewer1.ShowParameterPrompts = true;
ReportViewer1.ServerReport.SetParameters(
Request.QueryString.AllKeys
.Where(key => key != "report_name")
.Select(key => new ReportParameter(key, Request.QueryString[key]) {Visible = false})
);
}
private class EstamReportServerCredentials : IReportServerCredentials
{
public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority)
{
authCookie = null;
userName = null;
password = null;
authority = null;
return false;
}
public WindowsIdentity ImpersonationUser
{
get { return null; }
}
public ICredentials NetworkCredentials
{
get
{
return new NetworkCredential(
ConfigurationManager.AppSettings["ReportServerUser"],
ConfigurationManager.AppSettings["ReportServerPassword"],
ConfigurationManager.AppSettings["ReportServerDomain"]);
}
}
}
}
}
我们并没有做什么疯狂的事情,只是在展示一份报告。当我们在调试器中本地运行应用程序时,它工作得很好。将应用程序部署到IIS时,会显示报告,但工具栏不显示图像,导出功能也不起作用。
任何帮助都将是非常感激的。
这可能是由于Visual Studio开发web服务器和IIS之间的差异,特别是IIS处理web.config的方式。
完整的解决方案请查看此帖子