I recently upgraded from v14.1.5 to v15.4.1 of Umbraco Commerce and I am running into an issue in the CartSurfaceController
code that I copied from the Demo Store. I am encountering the following error on this line of code:
var order = await _commerceApi.GetOrCreateCurrentOrderAsync(store.Id) .AsWritableAsync(uow);
Error:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Umbraco.Commerce.Web
StackTrace:
at Umbraco.Commerce.Web.Session.CookieSessionStore.GetValue[T](String key)
at Umbraco.Commerce.Core.Session.SessionManager.<>c__DisplayClass43_0.<<GetDefaultShippingCountryAsync>b__0>d.MoveNext()
at Umbraco.Commerce.Core.Session.SessionManager.<WithSessionStoreAsync>d__101`1.MoveNext()
at Umbraco.Commerce.Core.Session.SessionManager.<>c__DisplayClass56_0.<<GetDefaultShippingMethodAsync>b__0>d.MoveNext()
at Umbraco.Commerce.Core.Session.SessionManager.<WithSessionStoreAsync>d__101`1.MoveNext()
at Umbraco.Commerce.Core.Session.SessionManager.<>c__DisplayClass14_0.<<GetOrCreateCurrentOrderAsync>b__1>d.MoveNext()
at Umbraco.Commerce.Core.UmbracoCommerceUnitOfWorkProvider.<ExecuteWithUnitOfWorkAsync>d__22`1.MoveNext()
at Umbraco.Commerce.Core.UmbracoCommerceUnitOfWorkProvider.<ExecuteWithUnitOfWorkAsync>d__22`1.MoveNext()
at Umbraco.Commerce.Core.Session.SessionManager.<GetOrCreateCurrentOrderAsync>d__14.MoveNext()
at Umbraco.Commerce.Core.Session.SessionManager.<GetOrCreateCurrentOrderAsync>d__13.MoveNext()
at Umbraco.Commerce.Extensions.AggregateBaseExtensions.<AsWritableAsync>d__7.MoveNext()
at GeneTools.Core.Web.Controllers.CartSurfaceController.<>c__DisplayClass2_0.<<AddToCart>b__0>d.MoveNext() in C:\dev\genetools\src\GeneTools.Core\Web\Controllers\CartSurfaceController.cs:line 36
This exception was originally thrown at this call stack:
[External Code]
GeneTools.Core.Web.Controllers.CartSurfaceController.AddToCart.AnonymousMethod__0(Umbraco.Commerce.Common.IUnitOfWork) in CartSurfaceController.cs
Is there something I need to change regarding Session/Cookies when upgrading to v15?