Vidya Vidya - 2 days ago 4
ASP.NET (C#) Question

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

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 .

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

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

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 .

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

Answer

I could guess that you have a problem with a session here. You're checking SessionController.CurrentMember != null in Page_Load, but not in your 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.

Comments