serverhttpsecurity 缺少_请求失败,HTTP状态401:未经授权在SSRS

My Application is in Asp.Net MVC3 coded in C#, i have a SSRS solution in SQL Server Business Intelligence Developement Studio in Visual Studio 2008 , I'm calling the SSRS report through my Asp.Net MVC3 application. My application was running fine a couple of days back but suddenly i'm getting an error as follows:

My Error :

The request failed with HTTP status 401: Unauthorized.

My Attempts

My SSRS reports are deployed on my local server. I have my credential properly set in the datasource of my SSRS report solution.

I tried to add the tag in my web.config

I tried adding IReportServerCredentials reportCredentials = new ReportServerCredentials("MyUserName", "MyPassword", "ServerName");

I ran the Visual Studio as 'Run as Administrator'.

I tried the solution mentioned in this link Creating a key using RegEdit

Update

I tried the following solution as well but the same result : Unauthorized error in SSRS

None of the above solutions worked, but when i run the same solution on some other machine than the solutions works well and no error is displayed. Its only when i run the solution from my machine then i get the error The request failed with HTTP status 401: Unauthorized.

解决方案

I am also getting the same error,

The request failed with HTTP status 401: Unauthorized.

Let me share what I tried and it is working fine now.

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;

}

}

Inside page_load event,

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();

}

This worked for me!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值