2017-08-04 47 views
0

我已經在服務器上部署了我的ssrs項目和報告。現在我必須在我的asp.net 應用程序中使用它們。我寫了幾個鏈接中找到的基本代碼。但我認爲我不是 傳遞正確的服務器uri和rdl文件路徑。你能否讓我知道一些關鍵點 成功做到這一點?在asp.net中使用報告查看器從服務器使用rdl文件

我們必須在這個字段reportViewer.ServerReport.ReportServerUrl =?

1)它是報告管理器或其服務器路徑的URL。其實我有兩件事。 一個是網址,另一個是服務器報告server.I服務器名稱與報告服務器。但後來也它不工作

reportViewer.ServerReport.ReportServerUrl = new Uri("http://SomeIp/ReportServer"); 

如果我嘗試導航的URI,它表明我的瀏覽器和also.That 報告的目錄意味着它的正確和工作。我也有一個報告管理員的URL。我需要通過嗎? 但是,它也沒有工作。

2)我可能出錯的其他事情是報告文件路徑。我是否必須從我的應用程序提供文件路徑或 是託管或部署報告的服務器目錄的路徑。究竟可能是路徑

如果我瀏覽報表管理器URL,http://films.braintech-dev.com/Reports

在這裏我可以看到SSRS家裏有一個名爲「film.Reporting」文件夾中,我可以看到我的報告 「FilmSummaryReport」。

所以我用以下爲我的文件路徑

reportViewer.ServerReport.ReportPath = "/film.Reporting/FilmSummaryReport"; 

3)或者,我可能是錯的.rdl擴展。它需要嗎?但因爲互聯網延伸不是必需的。

通過我在使用報表查看器

Server Error in '/' Application. 

The request failed with HTTP status 401: Unauthorized. 

請有完整的代碼來看看收到此錯誤的方式

var objList = this._service.GetAllRecords() 

    ReportViewer reportViewer = new ReportViewer 
    { 
     ProcessingMode = ProcessingMode.Remote 
    }; 

    IReportServerCredentials irsc = new ReportServerConnection("film12/srs", "ssrs123", "http://films.braintech-dev.com/Reports"); 

    reportViewer.ServerReport.ReportServerCredentials = irsc; 

    reportViewer.ServerReport.ReportServerUrl = new Uri("http://SomeIp/ReportServer"); 

    reportViewer.ServerReport.ReportPath = @"/film.Reporting/FilmSummaryReport"; 

    reportViewer.Width = Unit.Percentage(100); 

    reportViewer.LocalReport.DataSources.Add(new 
     ReportDataSource("DataSet1", objList)); 

    reportViewer.LocalReport.Refresh(); 

    this.ViewBag.ReportViewer = reportViewer; 
    return this.View(); 
+0

你可以發佈你的整個代碼塊嗎?你正確使用'「http:// SomeIp/ReportServer」' –

+0

我已經添加了我的代碼。你能看一下嗎? – Sandy

+0

你爲什麼要從'ServerReport'切換到'LocalReport'? –

回答

0

如果網站運行此部署和Visual沒有運行Studio然後驗證應用程序池正在運行的用戶是否具有訪問報告的權限。

+0

其實原始密碼是「film12 \ srs」,但c sharp不允許我在字符串中反斜槓。所以我用了「film12/srs」。這也可能是它仍然是未經授權的原因。但是應該有一個相關的錯誤。密碼不匹配還是這樣? – Sandy

+0

在第一次我沒有使用網絡憑證。但是現在我已經實現了IReportServerConnection並且也通過了網絡連接。我不確定我錯在哪裏。 – Sandy

相關問題