我的应用程序是用Asp.Net MVC3
编码的C#
,在SQL Server Business Intelligence Developement Studio
中有一个Visual Studio 2008
的SSRS解决方案,我正在通过我的Asp.Net MVC3应用程序调用SSRS报告。几天前,我的应用程序运行良好,但突然间,我收到了如下错误:
我的错误:
The request failed with HTTP status 401: Unauthorized.
我的尝试
local server
上。我在我的SSRS报告解决方案的数据源中正确设置了我的凭据。<identity impersonate="true" userName="Domain\username" password="Password" />
中添加标记IReportServerCredentials reportCredentials = new ReportServerCredentials("MyUserName", "MyPassword", "ServerName");
'Run as Administrator'
的形式运行Visual。上述解决方案都不起作用,但当我在其他计算机上运行相同的解决方案时,解决方案工作得很好,并且没有显示错误。只有当我在机器上运行解决方案时,才会得到错误的The request failed with HTTP status 401: Unauthorized.
。
发布于 2015-11-04 11:32:31
我也犯了同样的错误,
The request failed with HTTP status 401: Unauthorized.
让我分享一下我所做的努力,现在一切都很顺利。
public class CustomSSRSCredentials : IReportServerCredentials
{
private string _SSRSUserName;
private string _SSRSPassWord;
private string _DomainName;
public CustomSSRSCredentials(string UserName, string PassWord, string DomainName)
{
_SSRSUserName = UserName;
_SSRSPassWord = PassWord;
_DomainName = DomainName;
}
public System.Security.Principal.WindowsIdentity ImpersonationUser
{
get { return null; }
}
public ICredentials NetworkCredentials
{
get { return new NetworkCredential(_SSRSUserName, _SSRSPassWord, _DomainName); }
}
public bool GetFormsCredentials(out Cookie authCookie, out string user,
out string password, out string authority)
{
authCookie = null;
user = password = authority = null;
return false;
}
}
在page_load
事件中,
if (!Page.IsPostBack)
{
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
IReportServerCredentials ssrscredentials = new CustomSSRSCredentials("MyUserName", "MyPassword", "ServerName");
ServerReport serverReport = ReportViewer1.ServerReport;
ReportViewer1.ServerReport.ReportServerCredentials = ssrscredentials;
serverReport.ReportServerUrl = new Uri("ReportPathKey");
serverReport.ReportPath = "/Reports/MyReport";
serverReport.Refresh();
}
这个对我有用!
发布于 2017-01-17 13:54:19
我也有同样的问题。一切正常,然后我在reportviewer中突然收到了401,而不是在调试模式(localhost)中的报告。我一直在摆弄设置让它在现场运行,所以我觉得我做错了什么.
尝试了一些事情,然后决定重新启动,然后猜怎么着?我的域名密码过期了,所以认证失败了!愚蠢愚蠢的我!
我想在这里加上我的解决方案,以防人们遇到同样愚蠢的情况,浪费宝贵的时间去找出他们做错了什么.
发布于 2013-10-08 12:39:17
尝尝这个
public void GetConnectionOfReportServer()
{
try
{
NetworkCredential credential = new NetworkCredential("administrator", "password@123", "Domain");
this.reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = credential;
//select where the report should be generated with the report viewer control or on the report server using the SSRS service.
this.reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;
this.reportViewer1.ServerReport.ReportServerUrl = new Uri(@"http://localhost/ReportServer");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
https://stackoverflow.com/questions/19247645
复制相似问题