Page 1 of 1

View Customer Profile Error from Order screen

Posted: Fri Dec 17, 2010 9:52 am
by SamsSteins
I can a customer profile from the order screen, except when a customer creates an account after placing an order as an anonymous user. Then when I go to the original order and click on customer profile I get the following error;


Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 22: CountryCode.DataBind();
Line 23: //INIT ADDRESS
Line 24: Address address = _User.PrimaryAddress;
Line 25: FirstName.Text = address.FirstName;
Line 26: LastName.Text = address.LastName;

Source File: d:\Domains\samssteins.com\wwwroot\Admin\People\Users\AddressBook.ascx.cs Line: 24

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
Admin_People_Users_AddressBook.Page_Init(Object sender, EventArgs e) in d:\Domains\samssteins.com\wwwroot\Admin\People\Users\AddressBook.ascx.cs:24
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnInit(EventArgs e) +99
System.Web.UI.UserControl.OnInit(EventArgs e) +77
System.Web.UI.Control.InitRecursive(Control namingContainer) +333
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +378

Version Information: Microsoft .NET Framework Version:2.0.50727.3615; ASP.NET Version:2.0.50727.3618

Re: View Customer Profile Error from Order screen

Posted: Mon Dec 20, 2010 6:11 am
by s_ismail
Have you customized some thing?

Re: View Customer Profile Error from Order screen

Posted: Mon Dec 20, 2010 9:56 am
by SamsSteins
No, I have not customized anything.

Re: View Customer Profile Error from Order screen

Posted: Tue Dec 21, 2010 7:22 am
by jmestep
I have had that happen occasionally and haven't completely tracked it down, but I think it might be because of store maintenance deleting anonymous users.

Re: View Customer Profile Error from Order screen

Posted: Thu Feb 17, 2011 8:00 am
by triplw
Yes, it's because the anonymous user was deleted. You can see that when you hover on the Profile button that the URL at the botton of the page shows UserId=0. I added a conditional statement in ~/Admin/Orders/OrderMenu.cs

Code: Select all

 protected void Page_Load(object sender, EventArgs e)
    {
        InitOrder();
        if (_Order != null)
        {
            string suffix = "?OrderNumber=" + _Order.OrderNumber.ToString() + "&OrderId=" + _OrderId.ToString();
            Summary.NavigateUrl += suffix;
            Payments.NavigateUrl += suffix;
            Shipments.NavigateUrl += suffix;
            History.NavigateUrl += suffix;
            DigitalGoods.NavigateUrl += suffix;
            GiftCertificates.NavigateUrl += suffix;
            Subscriptions.NavigateUrl += suffix;
            EditAddresses.NavigateUrl += suffix;
            EditOrderItems.NavigateUrl += suffix;
            string packslipUrl = Page.ResolveUrl("PackingList.aspx");

            //Triple W - no error for anonymous users
            if (_Order.UserId != 0)
                Customer.NavigateUrl += "?UserId=" + _Order.UserId.ToString();
            else
            {
                Customer.NavigateUrl = "";
                Customer.Text = "Anonymous User";
            }
            // End

            string fileName = Request.Url.Segments[Request.Url.Segments.Length - 1].ToLowerInvariant();
            switch (fileName)
            {
                case "addpayment.aspx":
                case "editpayment.aspx":
                case "capturepayment.aspx":
                case "voidpayment.aspx":
                case "refundpayment.aspx":
                    Payments.CssClass = "contextMenuButtonSelected";
......................