C# Reporting Services 2008:“;HTTP状态401:未经授权;问题

C# Reporting Services 2008:“;HTTP状态401:未经授权;问题,c#,sql,web-services,ssrs-2008,C#,Sql,Web Services,Ssrs 2008,每当我尝试列出报表服务器上的报表时,就会出现错误“请求失败,HTTP状态为401:Unauthorized”。奇怪的是,当我在我的开发人员机器上运行asp.net应用程序并点击服务器reporting services web服务url()时,它会工作,但当服务器上安装asp.net应用程序(运行iis 7)并点击相同的url时,我会得到错误。以下是我的设置: 服务器: SQL Server Reporting services 2008(不是R2) Web服务url: 客户 已创建代理Repo

每当我尝试列出报表服务器上的报表时,就会出现错误“请求失败,HTTP状态为401:Unauthorized”。奇怪的是,当我在我的开发人员机器上运行asp.net应用程序并点击服务器reporting services web服务url()时,它会工作,但当服务器上安装asp.net应用程序(运行iis 7)并点击相同的url时,我会得到错误。以下是我的设置:

服务器:

SQL Server Reporting services 2008(不是R2)

Web服务url:

客户

已创建代理ReportingServices2005.cs

Web.config已被删除

列出报告的代码:

<asp:ListView ID="lvReportList" runat="server">
<LayoutTemplate>
    <ul>
        <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
    </ul>
</LayoutTemplate>
<ItemTemplate>
    <li>
        <asp:HyperLink runat="server" ID="hpReportLink" NavigateUrl='<%#Eval("Url")%>'><%#Eval("Name")%></asp:HyperLink>
    </li>
</ItemTemplate>
<EmptyDataTemplate>
    <div>
        No reports to display.
    </div>
</EmptyDataTemplate>

在谷歌搜索了几个小时的论坛和文章后,我发现Windows Server中的一个名为“环回检查”(loopbackcheck)的安全功能导致了这个问题。发生这种情况是因为我的报表服务器和IIS服务器位于同一台计算机上,并且我使用完全限定的域名(FQDN:)访问报表。我通过简单地使用服务器名而不是域名来解决这个问题,即。我希望这对其他人有所帮助。

我今天遇到了一些其他需要检查的问题-请确保检查用户的Windows帐户是否未被锁定。这将导致对
/reportserver
的请求返回
401未授权

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
    string rWebServiceUrl = ConfigurationManager.AppSettings["RSWebserviceUrl"];
    string reportServerFolder = ConfigurationManager.AppSettings["ReportServerFolder"];
    string domain = ConfigurationManager.AppSettings["RSDomain"];
    string userName = ConfigurationManager.AppSettings["RSUsername"];
    string password = ConfigurationManager.AppSettings["RSPassword"];

    objRS.Url = rWebServiceUrl;
    objRS.Credentials = new NetworkCredential(userName, password, domain);

    ReportingServices2005.CatalogItem[] items = objRS.ListChildren(reportServerFolder, false);

    var reportList = from p in items
                     select new
                     {
                         Name = p.Name,
                         Url = String.Format("{0}?reportPath={1}/{2}", ReportViewerUrl, reportServerFolder, p.Name)
                     };

    lvReportList.DataSource = reportList;
    lvReportList.DataBind();

}
}