C# System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9974813/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 11:26:55  来源:igfitidea点击:

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

c#asp.netexception

提问by Vidya

I am getting the below exception in a UserControl, Page Load. I have tried searching for this on Google, but have not found much information. Please let me know if anybody could help me with the same .

我在 UserControl,页面加载中收到以下异常。我试过在谷歌上搜索这个,但没有找到太多信息。请让我知道是否有人可以帮助我。

The situation is, there is one ascx.cs file for various usercontrols in different languages.

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

The application is running properly , but this exception is getting thrown for sometimes.

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

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)

Request information: Is authenticated: True Authentication Type: Forms Thread account name: IIS APPPOOL\SLC Website

请求信息:是否已通过身份验证:True 身份验证类型:Forms 线程帐户名: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;
            }
        }

Please find the BoundAccountsofMember method code behind .

请找到后面的 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;
            }
        }

The above exception is being thrown from Page_Load event. Regards Srividhya

上述异常是从 Page_Load 事件抛出的。问候斯里维提亚

采纳答案by Sergei B.

I could guess that you have a problem with a session here. You're checking SessionController.CurrentMember != nullin Page_Load, but not in your BoundAccountsOfMember.

我猜你在这里的会话有问题。你检查SessionController.CurrentMember != nullPage_Load,但不是在你的BoundAccountsOfMember

I believe that is a problem here if you're saying it happens time to time. You probably should work on session renewal/invalidation in your modules to make sure your code will not run without a valid session.

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