2010-09-28 96 views
9

每當我嘗試在報告服務器上列出報告時,我都會收到錯誤「請求失敗,HTTP狀態401:未經授權」。奇怪的是,它在我的開發機器上運行asp.net應用程序時碰到了服務器報告服務Web服務url(http://www.example.com/reports/reportservice2005.asmx?wsdl),但當服務器上安裝了asp.net應用程序(運行iis 7)時,它工作正常網址我得到的錯誤。這裏是我的設置:Reporting Services 2008:「HTTP狀態401:未授權」問題

服務器:

SQL Server報告服務2008(未R2)

Web服務網址:http://www.example.com/reports/reportservice2005.asmx?wsdl

客戶

創建代理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> 

代碼背後:

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(); 

} 
} 
+1

這是什麼'objRS'? – 2012-07-12 13:27:36

回答

13

幾個小時,谷歌搜索許多論壇和文章後,我發現,在Windows Server中的安全功能稱爲「環回檢查「(http://support.microsoft.com/kb/926642)是造成這個問題。發生這種情況是因爲我的報告服務器和IIS服務器都位於同一臺計算機上,並且我使用的是完全限定的域名(FQDN:http://www.example.com/reportserver)來訪問報告。我通過簡單地使用服務器的名稱而不是域名解決了這個問題,例如。我希望這可以幫助別人。

2

還有其他事情可以檢查我今天遇到了什麼 - 請務必檢查用戶的Windows帳戶沒有被鎖定。這將導致請求/reportserver返回401 not authorized

相關問題