SQL Server Reporting Services:报表查看器在本地运行,而不是在服务器上运行

发布于 2024-11-24 08:13:09 字数 3259 浏览 2 评论 0原文

我们在使用 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 时,会显示报告,但工具栏不显示图像,并且所有导出功能都不起作用。

任何有关这方面的帮助将不胜感激。

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 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩于岁月 2024-12-01 08:13:09

这可能是由于 Visual Studio 开发 Web 服务器和 IIS 之间的差异造成的,特别是 IIS 处理 web.config 的方式。

请检查此post 以获得完整的解决方案。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文