10

私のアプリケーションは に Asp.Net MVC3コード化されてC#ます. 私のアプリケーションは数日前に正常に動作していましたが、突然次のようなエラーが発生しました:SQL Server Business Intelligence Developement StudioVisual Studio 2008

私のエラー:

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. このリンクに記載されている解決策を試しましたRegEditを使用してキーを作成する

  6. 更新 次の解決策も試しましたが、同じ結果になりました: SSRS での権限のないエラー

上記の解決策はどれもうまくいきませんでしたが、同じ解決策を別のマシンで実行すると、解決策はうまく機能し、エラーは表示されません。マシンからソリューションを実行した場合にのみ、エラーが発生しますThe request failed with HTTP status 401: Unauthorized.

4

7 に答える 7

3

私も同じエラーが発生しています、

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

これは私のために働いた!

于 2015-11-04T11:32:31.960 に答える
2

これを試して

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


        }
于 2013-10-08T12:39:17.087 に答える
0

リクエストは http ステータス 401 無許可で失敗しました。2008年SSRS

from web.config add key="RS_UName" value="rajiv-pc" ---- 不正解

上記の値を、rajiv-pc のような SQL サーバー名ではなく、システム名 (rajiv) に置き換えます。

常にSQLサーバー名ではなくシステム名があります。

from web.config add key="RS_UName" value="rajiv" --- 正しい

于 2013-11-06T08:14:58.053 に答える
0

好奇心旺盛な人の答えが私の問題を解決しました。ありがとう!

また、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>

`

公開トークンは同じでなければなりません。そうしないと、別のエラーが発生します。

于 2015-12-02T02:39:08.243 に答える