First some background, we are creating a new "eGov" application. Eventually, a citizen can request permits and pay for licenses along with pay their utility bills and parking tickets online. Our vision has a shopping cart so a person can pay for multiple items in one transaction. To keep things organized better, we are going to break each section into a different project. This also allows me to work on one project while the other developer works another. The person making a payment could be a registered user or could remain unregistered. We feel a person from out of our jurisdiction probably doesn't want to register just to pay their parking ticket or pay for a one-time business license.
This project will be on Windows Server 2008 and IIS7 and using ASP.NET MVC 3. We will probably use a single domain (maybe egov.domain.gov) and in multiple sub directories (/cart, /permit, /billing, etc) though that is not 100% decided yet.
Now the problem. How do we track a shopping cart across multiple projects? There was talk of using a cookie that expires at a certain point or using a state machine. We are uncertain if using a session id would work. If we use a state machine, I have never used that and only understand it in concept (it works across multiple machines and SO uses it).
One other note, we are going to be building this on a VMWare server, so the possibility of having this run across multiple servers is a possibility in the future.
What would you use and why?
Update: It appears like many seem to recommend storing the cart in HttpContext. Is this the same across multiple applications?
First you need to setup your SQL Server to accept session state connections.
Then add the following to your Web.config file:
I then created a class library that has two classes:
Cart
andCartItem
.CartItem
defined to hold each individual shopping cart itemCart
works with your shopping cartTo test this, first in my shopping cart project in my home controller I did the following:
In my second project's home controller, I added the following:
This seemed to work for me great.