System.Web.UI.Page.ProcessRequestMain(布尔值包括同步点之前的阶段,布尔值包括异步点

本文关键字:布尔值 包括 异步 同步 UI Web Page ProcessRequestMain System | 更新日期: 2023-09-27 18:29:47

我在UserControl页面加载中得到以下异常。我试过在谷歌上搜索这个,但没有找到太多信息。如果有人能帮我做同样的事,请告诉我。

情况是,有一个ascx.cs文件用于不同语言的各种用户控件。

应用程序运行正常,但有时会引发此异常。

Exception information: 
Exception type: NullReferenceException 
Exception message: Object reference not set to an instance of an object.
at SmartSoft.SmartLiveWeb.UserControls.Common.PayoutForms.BoundAccountsOfMember()
at SmartSoft.SmartLiveWeb.UserControls.Common.PayoutForms.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

请求信息:已通过身份验证:True身份验证类型:表单线程帐户名称:IIS APPPOOL''SLC网站

protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                /*
                if (Request.QueryString.Count > 0 && Request.QueryString["MId"] != null)
                    this.MId = int.Parse(Request.QueryString.Get("MId"));
                */
                HideAllForms();
                AddValidationAttributesToControls();
                **BoundAccountsOfMember();**
                BoundWithdrawMethods();
                /*
                 * if (IsNetentConfirmationRequired())
                    LoadNetentConfirmationForm();
                 * 
                */
                CurrentPayoutMethod = (PayoutMethodEnum)Convert.ToInt16(SessionController.GetSessionData<object>("PayoutMethod"));
            }
            PlaceHolder phWithdraw = this.FindControl("phWithdraw") as PlaceHolder;
            Panel pnlKYC = this.FindControl("pnlKYC") as Panel;
            if (SessionController.CurrentMember != null && SessionController.CurrentMember.Approved == 10)
            {
                phWithdraw.Visible = false;
                pnlKYC.Visible = true;
            }
            else
            {
                phWithdraw.Visible = true;
                pnlKYC.Visible = false;
            }
        }

请查找后面的BoundAccountsofMember方法代码。

private void BoundAccountsOfMember()
        {
            Dictionary<Int16, AccountType> accountTypes = SessionController.CurrentMember.GetAccountTypes();
            ddlWithdrawFrom.Items.Clear();
            foreach (AccountType accountType in accountTypes.Values)
            {
                ddlWithdrawFrom.Items.Add(new ListItem(accountType.AccountName, accountType.AccountId.ToString()));
            }
            ListItem li = ddlWithdrawFrom.Items.FindByValue(SessionController.DefaultAccountId.ToString());
            if (li != null)
            {
                ddlWithdrawFrom.SelectedIndex = -1;
                li.Selected = true;
            }
        }

以上异常是从Page_Load事件引发的。当做Srividhya

System.Web.UI.Page.ProcessRequestMain(布尔值包括同步点之前的阶段,布尔值包括异步点

我猜您在这里的会话有问题。您正在Page_Load中检查SessionController.CurrentMember != null,但未在BoundAccountsOfMember中检查。

如果你说这种情况时有发生,我相信这就是一个问题。您可能应该在模块中处理会话续订/无效问题,以确保您的代码在没有有效会话的情况下不会运行。