2
votes

I have a asp.net c# web application with contains reports in remote processing mode. I am using the report-viewer control to render the reports. When I run the application in debug mode, I'm able to view my reports however when I publish the application to a different server I get this error message:

The request failed with HTTP status 401: Unauthorized.

My report server is on a different server than the location of my published web application. I have added new role assignment to my report server and also added to my web.config but the error persists. I think I am missing something in my aspx page for reportviewer.

Any input would be appreciated.

2

2 Answers

2
votes

I'm assuming you already have set the server in your codebehind such as this

reportviewer.ServerReport.ReportServerUrl = "http://{server_ip}/reportserver";

or via the properties of the report viewer control. Make sure you change {server_ip} to the actual for the report server.

Other such problems I've seen in the past have to do with access for individual reports. Since this is cross-server, you'll need a proxy user set to view the reports.

Here are 2 examples from MSDN:

Example 1

Example 2

0
votes

Yes! use Page_Load & Page_Init in this way

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    ReportViewer1.Visible = True
    Dim strReportsFolder As String = ConfigurationManager.AppSettings("ReportsFolder")
    Dim reportName As String = "report1"
    ReportViewer1.ServerReport.ReportPath = strReportsFolder + reportName

End Sub

Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs)

    PopulateReport(ReportViewer1, "")

End Sub

Public Shared Sub PopulateReport(ByVal rptViewer As ReportViewer, ByVal reportName As String)

    Dim strReportServer As String = ConfigurationManager.AppSettings("ReportServer")
    Dim strUserName As String = ConfigurationManager.AppSettings("Username")
    Dim strPassword As String = ConfigurationManager.AppSettings("Password")
    Dim strDomain As String = ConfigurationManager.AppSettings("Domain")

    rptViewer.ServerReport.ReportServerUrl = New Uri(strReportServer)
    rptViewer.ServerReport.ReportServerCredentials = New ReportViewerCredentials(strUserName, strPassword)

End Sub