当我使用与本地主机相同的凭据运行代码时,它可以正常工作,但是当我将其部署到服务器时,它给了我以下错误:
请求失败,HTTP状态为401:未授权。
我尝试为特定用户提供报告服务器的权限,报告服务器url在服务器和本地主机中分别工作,并且具有相同的凭据,也尝试了<identity impersonate="true"/>
,但是没有运气,我的代码如下:
string UserName = System.Configuration.ConfigurationManager.AppSettings["SsrsUserName"];
//added by nilesh
string Password = System.Configuration.ConfigurationManager.AppSettings["SsrsPassword"];
//added by nilesh
// string ReportUrl = System.Configuration.ConfigurationManager.AppSettings["MileageReport"];
//added by nilesh
// string ReportServer = System.Configuration.ConfigurationManager.AppSettings["ReportServer"];
string folder = System.Configuration.ConfigurationManager.ConnectionStrings["rptfolder"].ProviderName;
string reportURL = "";
reportURL = System.Configuration.ConfigurationManager.ConnectionStrings["rpturl"].ProviderName;
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new Uri(reportURL);
ReportViewer1.ServerReport.ReportPath = folder + "MileageReport";
//ReportViewer1.ServerReport.ReportPath = folder + "testReport";
//added by nilesh
IReportServerCredentials irsc = new ReportCredentials(UserName, Password, System.Configuration.ConfigurationManager.ConnectionStrings["domain"].ProviderName);
ReportViewer1.ServerReport.ReportServerCredentials = irsc;
// bool isauthenticated = ReportViewer1.ServerReport.ReportServerCredentials.ImpersonationUser.IsAuthenticated;
UserDataClass.LogError(userData.userId, "Not Error " + " UserName " + UserName + " Password " + Password + " Domain " + System.Configuration.ConfigurationManager.ConnectionStrings["domain"].ProviderName + " ReportPath " + ReportViewer1.ServerReport.ReportPath + " reportURL " + ReportViewer1.ServerReport.ReportServerUrl );
// ReportViewer1.ServerReport.ReportServerCredentials = new ReportServerNetworkCredentials();
ReportParameterInfoCollection pInfo = default(ReportParameterInfoCollection);
System.Collections.Generic.List<ReportParameter> paramList = new System.Collections.Generic.List<ReportParameter>();
paramList.Add(new ReportParameter("StartDate", startDate.ToString("dd-MMM-yyyy"), false));
paramList.Add(new ReportParameter("EndDate", endDate.ToString("dd-MMM-yyyy"), false));
paramList.Add(new ReportParameter("DeviceId", "ALL", false));
paramList.Add(new ReportParameter("DQCustId", Convert.ToString(userData.customerId), false));
paramList.Add(new ReportParameter("UserId", Convert.ToString(userData.userId), false));
ReportViewer1.ServerReport.SetParameters(paramList);
pInfo = ReportViewer1.ServerReport.GetParameters();
// ReportViewer1.ShowParameterPrompts = false;
ReportViewer1.ServerReport.Refresh();
答案 0 :(得分:0)
Ssrs服务器配置的发现 错误请求失败,HTTP状态为401:未授权。 此错误的确切含义是,如果您使用的是正确的凭据,则报告网址错误,则不会返回任何内容。 基本上,如果我们使用本地,则可以将ssrs用作本地服务器,也可以将其用作远程服务器,那么我们可以轻松地在项目内部提供rdlc的路径,但是如果我们为ssrs使用远程服务器设置,则需要为服务器提供URL和域名身份验证。 如果我们正在配置远程服务器报告,那么报告需要窗口凭证,因此请首先检查并确认凭证(用户名和密码)。 然后,您需要确认域名必须与报表服务网址中提到的域名相同 http://dqgpsnew/ReportServer这里的dqgpsnew是域名,因此在报表服务器的url和网络凭据的域名应该是相同的“ dqgpsnew” 如果您是从本地主机请求的,则将其替换为ip地址dqgpsnew到13.90.150.102,并报告服务器网址,例如http://13.90.150.102:80/ReportServer 如果我们不替换它,它将显示“无法解析的远程名称:'dqgpsnew'”