Request Error with HTTP Status 401: Unauthorized IN SSRS

My application is in Asp.Net MVC3 encoded in C# , I have an SSRS solution in SQL Server Business Intelligence Developement Studio in Visual Studio 2008 , I am invoking an SSRS report through my Asp.Net MVC3 expression. My application worked fine a couple of days ago, but suddenly I get an error message as follows:

My mistake:

 The request failed with HTTP status 401: Unauthorized. 

My attempts

  • My SSRS reports are deployed to my local server . I have my credentials set correctly in the data source of my SSRS solution.

  • I tried adding a tag to my web.config <identity impersonate="true" userName="Domain\username" password="Password" />

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

  • I started Visual Studio as 'Run as Administrator' .

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

  • Update I also tried the following solution, but the same result: Unauthorized error in SSRS

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

+8
c # sql-server asp.net-mvc-3 reporting-services ssrs-2008
source share
5 answers

try it

 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
source

I also get the same error

 The request failed with HTTP status 401: Unauthorized. 

Let me share what I tried, and now it works fine.

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

It worked for me!

+2
source

The request failed with an unauthorized HTTP status of 401. ssrs 2008

from web.config add key = "RS_UName" value = "rajiv-pc" ---- invalid

replace the value above with your system name (rajiv) and not with the sql server name, for example rajiv-pc

there is always a system name, not a sql server name.

from web.config add key = "RS_UName" value = "rajiv" --- correct

0
source

curiousguy answer solved my problem. thanks man!

Also check your web.config. It should have the following:

`

 <system.web> <httpHandlers> <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" validate="false" /> </httpHandlers> </system.web> <system.webServer> <handlers> <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /> </handlers> </system.webServer> 

`

The open token must be the same, otherwise it will lead to another error.

0
source

I had the same problem. Everything worked fine, and then slowly I get 401 in an iframe reportviewer instead of my report in debug mode (localhost). I played with the settings to run it on the site, so I thought I did something wrong ...

I tried several things, and then decided to just reboot and guess what ??? My domain password has expired, so authentication failed !!! Silly silly silly me!

I think that I will add my decision here if people face the same stupid situation and lose valuable time figuring out what they did wrong ...

0
source

All Articles