开发者

SQL Server Reporting Services: Report Viewer works locally, not on server

We are having a problem with SSRS and the Report Viewer. We are using a simple aspx page to show our reports:

    <%@ 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 开发者_StackOverflow社区NetworkCredential(
                        ConfigurationManager.AppSettings["ReportServerUser"],
                        ConfigurationManager.AppSettings["ReportServerPassword"],
                        ConfigurationManager.AppSettings["ReportServerDomain"]);
                }
            }
        }
    }
}

We're not doing anything crazy here, simply showing a report. When we run the application locally in the debugger it works fine. When the application is deployed to IIS, the reports are displayed, but the toolbar doesn't show images and none of the export functionality works.

Any help with this would be GREATLY appreciated.


It is probably due to a difference between Visual Studio development web server and IIS, specifically the way IIS handles web.config.

Please check this post for the complete solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜