我正在构建一个包含 SQL Server 报告查看器的 ASP .NET Web 应用程序。查看器由 Microsoft.ReportingServices.ReportViewerControl.WebForms 包提供。
当使用本地主机连接时,报告显示正常,但当使用域名(www.example.com)连接时,会出现以下文本:
授予用户“hardcodeddomain\hardcodeduser”的权限不足以执行此操作。 (rsAccessDenied)
我不知道为什么使用不同的主机名会改变结果,但应用程序非常简单。
Reports.aspx
<%@ Page Title="Title" Language="C#" MasterPageFile="~/Site.Master" CodeBehind="Reports.aspx.cs" Inherits="ReportingPortal.WebForms.Reports" %>
<%@ Register TagPrefix="rsweb" Namespace="Microsoft.Reporting.WebForms" Assembly="Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<rsweb:ReportViewer Width="100%" ID="ReportViewer" runat="server" ProcessingMode="Remote">
<ServerReport></ServerReport>
</rsweb:ReportViewer>
</asp:Content>
Reports.aspx.cs
using System;
using System.Configuration;
using System.Web.UI;
namespace ReportingPortal.WebForms
{
public partial class Reports : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) return;
ReportViewer.ServerReport.ReportServerCredentials = new ReportServerCredentials();
ReportViewer.ServerReport.ReportPath = "/example/report/path";
ReportViewer.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings.Get("ReportServerUrl"));
}
}
}
有人知道为什么会这样吗?
出于某种原因,这会影响用户是否可以通过域名访问报告。我认为“站点设置”中的安全性就足够了,但显然不够!