简体   繁体   English

错误请求失败,HTTP状态为401:未经授权

[英]Error The request failed with HTTP status 401: Unauthorized

When i run code with same credential with localhost it works properly but when i deploy it to server it is giving me the below error: 当我使用localhost运行具有相同凭据的代码时,它可以正常工作,但是当我将其部署到服务器时,它给出了以下错误:

The request failed with HTTP status 401: Unauthorized. 请求失败,HTTP状态为401:未授权。

I have tried permission to report server for particular user report server url is working separately in server and localhost both with same credentials also tried <identity impersonate="true"/> but no luck, my code is below: 我已经尝试为特定用户报告服务器报告服务器的权限url在服务器和localhost中单独工作,两者都使用相同的凭据也尝试<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();

Findings for Ssrs server configuration Error The request failed with HTTP status 401: Unauthorized. Ssrs服务器配置的结果错误请求失败,HTTP状态为401:未经授权。 This error exactly means that if you are using correct credentials then report url is wrong it doesn't returning anything. 此错误确切意味着如果您使用正确的凭据,则报告url是错误的,它不会返回任何内容。 Basically we can use ssrs as local server and as remote server if we are using local then we can easily give path of rdlc inside our project but if we are using remote server setup for ssrs then we need to giver report server url and domain name for authentication. 基本上我们可以使用ssrs作为本地服务器和远程服务器如果我们使用本地然后我们可以很容易地在我们的项目中提供rdlc的路径但是如果我们使用ssrs的远程服务器设置那么我们需要提供报告服务器URL和域名认证。 If we are configuring remote server report then report needs window credential ,so first please check and confirm credential (username and password). 如果我们正在配置远程服务器报告,则报告需要窗口凭据,因此请首先检查并确认凭据(用户名和密码)。 Then you need to confirm that domain name must be same as mentioned in report service url http://dqgpsnew/ReportServer here dqgpsnew is domain name so in report server url and domain name for network credential should be the same “dqgpsnew” if you are requesting it from local host then this is replaced it by ip address dqgpsnew to 13.90.150.102 and report server url like http://13.90.150.102:80/ReportServer if we donot replace it then it will give “the remote name could not be resolved: 'dqgpsnew'” 然后你需要确认域名必须与报告服务网址中提到的相同http:// dqgpsnew / ReportServer这里dqgpsnew是域名所以在报告服务器网址和网络凭证的域名应该是相同的“dqgpsnew”如果你是从本地主机请求它然后这被IP地址dqgpsnew替换为13.90.150.102并报告服务器URL如http://13.90.150.102:80/ReportServer如果我们不替换它然后它将给出“远程名称不能是解决:'dqgpsnew'“

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 请求失败,HTTP状态为401:未经授权 - The request failed with HTTP status 401: Unauthorized 请求失败,HTTP状态为401:未授权。 - The request failed with HTTP status 401: Unauthorized. 请求失败,HTTP 状态为 401:未授权 IN SSRS - The request failed with HTTP status 401: Unauthorized IN SSRS 请求失败,HTTP 状态为 401:调用 Web 服务时未经授权 - The request failed with HTTP status 401: Unauthorized while calling web service 请求失败,HTTP状态为401:再次尝试未授权 - Request failed with HTTP status 401: Unauthorized on second try 在C#窗口应用程序中SSRS报告呈现中出现错误:请求失败,HTTP状态为401:未经授权 - Getting Error in SSRS report rendering in C# window application: The request failed with HTTP status 401: Unauthorized 服务器无法处理请求。 ---&gt;请求失败,HTTP状态为401:未经授权 - Server was unable to process request. ---> The request failed with HTTP status 401: Unauthorized 请求失败,HTTP状态为401:未授权 - IIS升级 - WebService和Web应用程序 - The request failed with HTTP status 401: Unauthorized - IIS Upgrade - WebService & Web Application 我有一个运行Windows窗体的应用程序在具有SRSS报告提示错误的LAN上运行HTTP请求失败401未经授权,但在我的PC上运行良好 - I Have a windows form application running on LAN having SRSS Report prompting error The HTTP request failed 401 unauthorized but running fine on my pc 请求失败。 远程服务器返回错误:(401)连接到Office365时出现未授权错误 - The request failed. The remote server returned an error: (401) Unauthorized error while connecting to Office365
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM