This is just a guess, but as I put in my comment above, it looks like your first call to Session isn't creating an error (where you get the ShoppingCart
instance from Session).
It looks like you're trying to retrieve the list of items from ShoppingCart
. Since you already have the instance (in your first call to Session), all you need to do is access the property (if you have one) that contains the list of items in the cart, like this:
ShoppingCart sCart = (ShoppingCart)Session["UserCart"];
List<CartItem> cartItems = sCart.Items;
The above is based on ShoppingCart
having a property called Items
that returns a list of of CartItem
.
The way you were doing it you were telling the compiler to get the ShoppingCart
instance from Session and convert it to a List of CartItems
, hence the error as I doubt ShoppingCart
and CartItems
are the same object :)