简体   繁体   中英

Getting Error in SSRS report rendering in C# window application: The request failed with HTTP status 401: Unauthorized

I have 1 SSRS Report that deployed on server. I am able to access and see the report in ReportViewer in Test Application(C# Window Application). But I am not able to access/run the same report in my actual actual application with same piece of code., getting error on the line where I am setting parameters to reportviewer.

Here is the code block that i am using in both Test and Actual Application:

ReportParameter[] parameters = new ReportParameter[3];

            rptViewer.Reset();
            rptViewer.ProcessingMode = ProcessingMode.Remote;
            rptViewer.ServerReport.ReportPath = "/LIVE Reports/LicenceReport";
            rptViewer.ServerReport.ReportServerUrl = new Uri(@"http://X3dRF45CC/Reportserver", System.UriKind.Absolute);

            parameters[0] = new ReportParameter("IN_TIME_PERIOD_FLAG", txtType.Text, false);
            parameters[1] = new ReportParameter("IN_PLAN_VERSION_ID", txtPlanVersion.Text, false);
            parameters[2] = new ReportParameter("IN_MEDIA_OUTLET_ID", txtNetwork.Text, false);

            // Getting error at this below line in Actual App (but not in Test App)
            rptViewer.ServerReport.SetParameters(parameters);

            rptViewer.RefreshReport();

Please someone help, I am wondering from last 2 days.

If your report server is running under windows authentication. Then it is possible that when you run the report using test application (which is running with user context having correct permissions) it runs fine. But when you run this in the actual application(which is not running in context of user with appropriate permissions) fails with 401 (UnAuthorized) error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM