I'm implementing a simple session cart for unauthenticated users in ASP.NET MVC and I want to do it right.
In the past I have always stored the cart ID in the persistent Session["CartID"]
store and as a cookie. Whenever I need to display the cart, I'll look up the user's cart items from my Carts
and CartItems
tables. But inside I know a more strongly-typed approach would be cleaner.
After Googling for the latest session MVC stuff, I found the term HttpSessionStateWrapper
, which seems to be a testable way of dealing with sessions. But I have not found any good tutorials or standardised implementations. Maybe it's just a buzz-word and I should be sticking to Session["..."]
.
What is the right way to implement a shopping cart using sessions in the latest version of ASP.NET MVC?