首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >HTTP状态401: SSRS中未经授权的请求失败

HTTP状态401: SSRS中未经授权的请求失败
EN

Stack Overflow用户
提问于 2013-10-08 12:25:54
回答 8查看 54.3K关注 0票数 11

我的应用程序是用Asp.Net MVC3编码的C#,在SQL Server Business Intelligence Developement Studio中有一个Visual Studio 2008的SSRS解决方案,我正在通过我的Asp.Net MVC3应用程序调用SSRS报告。几天前,我的应用程序运行良好,但突然间,我收到了如下错误:

我的错误:

代码语言:javascript
运行
复制
The request failed with HTTP status 401: Unauthorized.

我的尝试

  1. 我的SSRS报告部署在我的local server上。我在我的SSRS报告解决方案的数据源中正确设置了我的凭据。
  2. 我试图在我的web.config <identity impersonate="true" userName="Domain\username" password="Password" />中添加标记
  3. 我试着添加IReportServerCredentials reportCredentials = new ReportServerCredentials("MyUserName", "MyPassword", "ServerName");
  4. 我以'Run as Administrator'的形式运行Visual。
  5. 我尝试了这个链接使用RegEdit创建密钥中提到的解决方案
  6. Update I也尝试了以下解决方案,但结果相同:SSRS中的未经授权错误

上述解决方案都不起作用,但当我在其他计算机上运行相同的解决方案时,解决方案工作得很好,并且没有显示错误。只有当我在机器上运行解决方案时,才会得到错误的The request failed with HTTP status 401: Unauthorized.

EN

回答 8

Stack Overflow用户

发布于 2015-11-04 11:32:31

我也犯了同样的错误,

代码语言:javascript
运行
复制
The request failed with HTTP status 401: Unauthorized.

让我分享一下我所做的努力,现在一切都很顺利。

代码语言:javascript
运行
复制
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事件中,

代码语言:javascript
运行
复制
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();
}

这个对我有用!

票数 5
EN

Stack Overflow用户

发布于 2017-01-17 13:54:19

我也有同样的问题。一切正常,然后我在reportviewer中突然收到了401,而不是在调试模式(localhost)中的报告。我一直在摆弄设置让它在现场运行,所以我觉得我做错了什么.

尝试了一些事情,然后决定重新启动,然后猜怎么着?我的域名密码过期了,所以认证失败了!愚蠢愚蠢的我!

我想在这里加上我的解决方案,以防人们遇到同样愚蠢的情况,浪费宝贵的时间去找出他们做错了什么.

票数 3
EN

Stack Overflow用户

发布于 2013-10-08 12:39:17

尝尝这个

代码语言:javascript
运行
复制
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);
            }


        }
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19247645

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档