1

我有一份 SSRS 报告,我在我的网络项目中调用此报告。我的客户端页面如下图所示:

网站

我的 .cs 页面代码是:

public reports()
{
    Init += Page_Init;
    Load += Page_Load;
}

protected void Page_Init(object sender, System.EventArgs e)
{
    ReportViewer1.ServerReport.ReportServerCredentials = new MyReportServerCredentials();
}

[Serializable()]
public sealed class MyReportServerCredentials : IReportServerCredentials
{
    public string UserName = ConfigurationManager.AppSettings["rvUser"];
    public string Password = ConfigurationManager.AppSettings["rvPassword"];

    public string Domain = ConfigurationManager.AppSettings["rvDomain"];
    public WindowsIdentity ImpersonationUser
    {
        //Use the default windows user.  Credentials will be
        //provided by the NetworkCredentials property.

        get { return null; }
    }

    public ICredentials NetworkCredentials
    {
        get
        {
            //Read the user information from the web.config file. 
            //By reading the information on demand instead of storing
            //it, the credentials will not be stored in session,
            //reducing the vulnerable surface area to the web.config
            //file, which can be secured with an ACL.

            if ((string.IsNullOrEmpty(UserName)))
            {
                throw new Exception("Missing user name from web.config file");
            }

            if ((string.IsNullOrEmpty(Password)))
            {
                throw new Exception("Missing password from web.config file");
            }

            if ((string.IsNullOrEmpty(Domain)))
            {
                throw new Exception("Missing domain from web.config file");
            }

            return new NetworkCredential(UserName, Password, Domain);
        }
    }

    public bool GetFormsCredentials(out Cookie authCookie,
              out string userName, out string password,
              out string authority)
    {
        authCookie = null;
         userName = UserName;
         password = Password;
         authority = Domain;
        // Not using form credentials
        return false;
    }



    private void ShowReport()
    {
        ReportViewer1.ProcessingMode = ProcessingMode.Remote;
        ReportViewer1.ServerReport.ReportServerUrl = new Uri(reportServer);
        ReportViewer1.ServerReport.ReportPath = "/xyz/ReportNewname";
        ReportParameter[] param = new ReportParameter[8];
        param[0] = new ReportParameter("p_ClientID", ClientID);
        param[1] = new ReportParameter("p_CarrierID", carrierId);
        param[2] = new ReportParameter("p_StartDate", BeginDate);
        param[3] = new ReportParameter("p_EndDate", EndDate);
        param[4] = new ReportParameter("p_ClaimSubTypeID", ClaimTypeID);
        param[5] = new ReportParameter("p_SalesAuditorId", SalesAuditorID);
        param[6] = new ReportParameter("p_IsPaid", PaidClaim);
        param[7] = new ReportParameter("p_IsOpen", OpenClaim);
        ReportViewer1.ServerReport.SetParameters(param);
}

我的问题是:第一次单击 GUI(索赔(付费))项目上的左侧树视图并输入开始日期和结束日期。报告工作正常。现在,假设在此之后我单击任何其他项目,例如- Claim(ALL) ,然后再次单击 (Claims(Paid)) 并提供相同的日期参数,它向我显示以下错误:

请求失败,HTTP 状态为 401:未授权。

如果我将它部署在 IIS 上并尝试运行它,它会显示此错误:

如果您已到达此页面,则存在导致 AFS Claims 显示该页面的错误。虽然我们尽一切努力确保您的用户体验没有错误,但有时遇到的错误可能不是我们所知道的。

请在浏览器中选择后退按钮并查看您尝试使用的最后一页。

请注意:出于安全考虑,即使您已选中复选框以记住您的登录信息,此网站上的登录用户也有会话时间限制。如果您已经超过了会话的超时时间,那么您尝试完成的操作很可能将不起作用。

有谁能够帮助我?为什么第一次有效,第二次无效?

4

1 回答 1

1

尝试将设置凭据部分放在 ShowReport() 方法中,而不是页面 init 方法中。设置断点以查看您的第二个请求中凭据的外观。

于 2013-08-07T02:32:49.703 回答