The shopping card in mvcmusicstore uses the session variable. That should be unique for each user.
The delete link is most likely caused by a path reference problem. I'm guessing you're deploying to a virtual directory (sub folder) in IIS. That often causes problems with hardcoded paths. MVC music store uses a jquery ajax post to delete the user. You
need to make sure you user @Url.Action instead of hardcoding in a path to the delete action method. In the shopping card index view. Make the following change:
//Change this line
$.post("/ShoppingCart/RemoveFromCart", { "id": recordToDelete },
//To this
$.post("@Url.Action("RemoveFromCart","ShoppingCart")", { "id": recordToDelete },
Basically instead of hardcoding in the url, we are letting the mvc framework resolve the url. If the application is local or an the site root, the framework will generate a url of /ShoppingCard/RemoveFromCart. But if the mvc applicationg is deployed a virtual
directory, it will now appear in the correct path.
CodeHobo
All-Star
18647 Points
2647 Posts
Re: Having problem with my shopping mvc?
Apr 18, 2012 10:15 PM|LINK
The shopping card in mvcmusicstore uses the session variable. That should be unique for each user.
The delete link is most likely caused by a path reference problem. I'm guessing you're deploying to a virtual directory (sub folder) in IIS. That often causes problems with hardcoded paths. MVC music store uses a jquery ajax post to delete the user. You need to make sure you user @Url.Action instead of hardcoding in a path to the delete action method. In the shopping card index view. Make the following change:
//Change this line $.post("/ShoppingCart/RemoveFromCart", { "id": recordToDelete }, //To this $.post("@Url.Action("RemoveFromCart","ShoppingCart")", { "id": recordToDelete },Basically instead of hardcoding in the url, we are letting the mvc framework resolve the url. If the application is local or an the site root, the framework will generate a url of /ShoppingCard/RemoveFromCart. But if the mvc applicationg is deployed a virtual directory, it will now appear in the correct path.
Blog | Twitter : @Hattan