2013-10-08 428 views
8

我的应用程序是在Asp.Net MVC3C#编码,我在Visual Studio 2008SQL Server Business Intelligence Developement Studio一个SSRS的解决方案,我打电话SSRS通过我Asp.Net MVC3申请报告。我的申请被罚款运行几天回去,但突然向我如下得到一个错误:请求失败,HTTP状态401:未经授权在SSRS

我的错误:

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. 我跑在Visual Studio为'Run as Administrator'

  5. 我想在这个环节Creating a key using RegEdit

  6. 提到的更新 的解决方案,我尝试了以下解决方案很好,但相同的结果:Unauthorized error in SSRS

上述解决方案的无工作,但是当我运行相同的解决方案,而不是解决方案运行良好,并没有显示错误。它只有当我运行从我的机器的解决方案,然后我得到的错误The request failed with HTTP status 401: Unauthorized.

+0

@KuldipMCA其实,不知道这是怎么固定的。有一天我尝试了我的解决方案,并没有遇到同样的问题。很奇怪。 –

回答

1

试试这个

public void GetConnectionOfReportServer() 
     { 
      try 
      { 
       NetworkCredential credential = new NetworkCredential("administrator", "[email protected]", "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); 
      } 


     } 
0

请求,HTTP状态401未经授权失败。 SSRS 2008

从web.config中添加关键= “RS_UName” 值= “拉吉夫-PC” ----不正确

与您的系统名称(拉吉夫)不是SQL服务器的名称,如拉吉夫-PC更换输入的值

总是有系统名称不是sql server名称。

从web.config中添加关键=“RS_UName”值=“拉吉夫” ---正确

2

我也得到同样的错误,

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

这为我工作!

+0

非常感谢你让我的一天..................... –

+1

非常欢迎你! :)快乐的日子(y) – pedram

0

curiousguy的回答解决我的问题。谢啦!

另外,检查你的web.config。它必须具有一定以下:

`

<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> 

`

公共令牌必须相同,否则将炸毁另一个错误。

0

我有同样的问题。一切工作正常,然后突然我收到报告查看器iframe中的401而不是我的报告在调试模式(本地主机)。我一直在摆弄与设置,以获得它的活动站点上运行,所以我认为我做错了什么......

试了几件事情,然后决定只重新启动,你猜怎么着???我的域名密码已过期,因此验证失败! 愚蠢愚蠢的我!

想我会在这里添加我的解决方案的情况下,人们遇到同样的愚蠢形势和宽松的宝贵时间搞清楚他们做了什么错?

相关问题