Page 1 of 1

Bug in minicart

Posted: Mon Jan 26, 2009 12:56 am
by eggheaddesign
Hi

We just spent some time figuring out an issue that has been reported on these forums but never answered.

The issue is this: the first time somebody browses to your site, they get an object null exception.

This is caused by a potential design flaw in the minicart. This component overrides the preinit event in order to find out who the current user is so that the basket can be populated.

It does this by calling a method in Token.Instance.User in order to find out who the user is. HOWEVER, the first time the user browses to the site, there is no session cookie, and the PreInit event is too early in the request/response cycle for the session cookie to be created. The Token.Instance.User object seems to have some deficiencies in that it returns without problem, but then when you try and do something with the basket, you get the null reference.

We did discover that if the user is unknown, the UserID returned for the User object is 0, so we fixed the problem by adding some code to the minicart to hide it if the UserID is zero.

If I'm honest, I regard this fix as being a bodge - the Token.Instance.User should have some clear way of communicating that the user is unknown.

All the Best

Tony

Re: Bug in minicart

Posted: Mon Jan 26, 2009 8:14 am
by mazhar
I am unable to reproduce the problem. Could you provide some more detailed information about the reproduction scenario? For example have you placed Minibasket at some location other then the default, is there any specific step involved to reproduce the problem. What is your application version information? Also could you please try to reproduce the problem here on the AbleCommerce 7 demo site.
http://demo.ablecommerce.com/ac7_stable/

Re: Bug in minicart

Posted: Mon Jan 26, 2009 8:32 am
by eggheaddesign
This problem only manifests itself when the first page on the site that the visitor lands on has a minicart on it, and when there is no cookies in the browser cache to identify the user.

Try this: clear your browser cache, and navigate to page that includes the mini basket.

We only spotted the behaviour when we included the minicart on all pages (a design goal of the client's) and released it to UAT - the client's browser had no cookies stored, and the problem showed up

We saw this problem reported but not resolved here:
viewtopic.php?f=42&t=9354&p=41300&hilit ... ecalculate
Cheers

Tony

Re: Bug in minicart

Posted: Mon Jan 26, 2009 8:42 am
by jmestep
I'm not sure what build you are using, but I don't have that problem when I checked several sites using Build 10863.

Re: Bug in minicart

Posted: Mon Jan 26, 2009 9:10 am
by mazhar
I have tried by removing all cookies and then placing the control on home page but still unable to reproduce the problem.

Re: Bug in minicart

Posted: Mon Jan 26, 2009 9:58 am
by gilesroberts
Our Able Commerce version is as follows:

PLATFORM: ASP.NET
VERSION: 7.1
BUILD: unknown

AjaxControlToolkit: 1.0.10301.0
AvalaraTaxProvider: 1.0.0.0
BPSUtility: 1.0.0.0
CommerceBuilder: 7.0.10576.0
CommerceBuilder.AbleCommerceTax: 7.1.0.0
CommerceBuilder.AustraliaPost: 7.1.0.0
CommerceBuilder.AuthorizeNet: 7.0.9764.0
CommerceBuilder.CanadaPost: 7.0.0.0
CommerceBuilder.CCH: 7.0.0.0
CommerceBuilder.Configuration: 7.0.10576.0
CommerceBuilder.CyberSource: 7.0.9764.0
CommerceBuilder.DataClient.Api: 1.0.0.21
CommerceBuilder.DataClient.Csv: 1.0.0.0
CommerceBuilder.DHL: 7.0.8825.0
CommerceBuilder.DHLInternational: 7.1.0.0
CommerceBuilder.ECB: 7.0.0.0
CommerceBuilder.FedEx: 7.0.9725.0
CommerceBuilder.FRBNY: 7.0.0.0
CommerceBuilder.GoogleCheckout: 7.0.10052.0
CommerceBuilder.InternetSecure: 7.0.9764.0
CommerceBuilder.LinkPoint: 7.0.9764.0
CommerceBuilder.Paradata: 7.0.9764.0
CommerceBuilder.PayFlowPro: 7.0.10061.0
CommerceBuilder.PayJunction: 7.0.9764.0
CommerceBuilder.PayPal: 7.1.10840.0
CommerceBuilder.Protx: 7.1.10124.0
CommerceBuilder.Services: 7.0.10576.0
CommerceBuilder.SkipJack: 7.0.9764.0
CommerceBuilder.UPS: 7.0.10041.0
CommerceBuilder.USPS: 7.0.9728.0
CommerceBuilder.Web: 7.0.10576.0
ComponentArt.Web.UI: 2007.1.1566.3
CyberSource.Base: 2.0.0.0
CyberSource.Clients: 5.0.2.0
CyberSource.Clients.XmlSerializers: 5.0.2.0
CyberSource.WSSecurity: 2.0.0.0
CybsWSSecurityIOP: 1.0.0.0
DataAccess: 1.0.0.0
edtFTPnet: 1.2.4.0
FredCK.FCKeditorV2: 2.5.2912.21007
ICSharpCode.SharpZipLib: 0.85.5.452
LinkPointTransaction: 1.0.1797.29766
log4net: 1.2.10.0
Microsoft.Practices.EnterpriseLibrary.Common: 2.0.0.0
Microsoft.Practices.EnterpriseLibrary.Data: 2.0.0.0
Microsoft.Practices.ObjectBuilder: 1.0.51205.0
Microsoft.Web.Preview: 1.2.61025.0
MySql.Data: 5.0.7.0
NVelocity: 7.0.8530.0
PaygatewayNET: 3.0.0.0
paypal_base: 4.2.1.0
PFProCOMLib: 1.0.0.0
PFProdotNET: 0.0.0.0
SubSonic: 2.0.3.0
Utility: 1.0.0.0
Validators: 1.0.0.0
WebChart: 1.1.1.6
wwHoverPanel: 1.85.0.0

See the last comment on thread viewtopic.php?f=42&t=9354&hilit=basket+recalculate for more information.

Re: Bug in minicart

Posted: Mon Jan 26, 2009 10:16 am
by eggheaddesign
gilesroberts wrote:Our Able Commerce version is as follows:
.....
Giles is a lead developer at Egghead....

Re: Bug in minicart

Posted: Thu Feb 26, 2009 3:58 pm
by Netfinity
Hi,
I get this issue too, but not with FF or IE. It is occurring only when I use Safari (Windows). I get the error:

Object reference not set to instance...

Code: Select all

Line 47:         Basket basket = Token.Instance.User.Basket;
Line 48:         basket.Package(true);
Line 49:         basket.Recalculate();
Line 50:         //VALIDATE THE BASKET
Line 51:         List<string> basketMessages = new List<string>();
Not sure at all what the issue is here but will have a go at cracking it.

Re: Bug in minicart

Posted: Fri Feb 27, 2009 3:56 am
by eggheaddesign
Try clearing the browser cache on the other browsers to see if you get the problem then.

Re: Bug in minicart

Posted: Fri Feb 27, 2009 6:12 am
by niall08
I used to get that error before the last update - did it involve Line 49 in minibasket.ascx.cs??

I just commented out "basket.Recalculate();" with no (noticed) ill-effects.