Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 29th, 2009, 05:46 PM
Authorized User
 
Join Date: Oct 2007
Location: , , .
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Red face Shopping Cart Crossing Over

Hi Imar,

I used Chapter 9 Webshop part of your book at my shopping site program. When my customer places on Order, he has his collegue's order item on his Shopping Cart screen. But I cannot generate same condition at my computer. Can you advise me how to approach to solve this problem?

Thanks,
HD
  #2 (permalink)  
Old June 29th, 2009, 06:40 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

This is absolutely not enough information for me to say something useful about it. Can you elaborate? Please be as specific as possible (the scenario that's been followed, systems setup, browsers used, the relation between the customer and the colleague (e.g. do they share the same login, browser, profile, PC and so on) etc etc. Also, please be clear about what you mean with "he has his collegue's order item on his Shopping Cart screen"/ An older order? From days ago? Weeks? Or the one the colleague is seeing on his screen at the same time?

Without all this information, I am in the same boat as you are ;-)

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #3 (permalink)  
Old June 29th, 2009, 08:40 PM
Authorized User
 
Join Date: Oct 2007
Location: , , .
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Shopping Cart Crossing Over

Hi Imar,

Thanks Imar for your kind reply.
The website is in IIS 7. Browser : IE7
They work at same office but different PC and different login.
His collegue's Order means; User A placed item A a few minutes ago, user B added his own items then user A's ordered item A appears in user B's Shopping Cart as well. But user A's screen is no problem. It looks user B's PC read user A's cookies.

Thanks agian Imar. You are always so kind to me and everyone.
HD
  #4 (permalink)  
Old June 30th, 2009, 03:33 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi again,

That is really strange.... The ShoppingCart is stored in Session state which should be unique to a user. The only reasons for this behavior that I can think of are:

1. You (or another programmer) made changes to the Wrox WebShop code and now store the shopping cart somewhere else so users can share data.

2. You're using cookieless sessions, user A went to the site, got a session identifier in the query string, sent a link to user B which then took over user A's session. A long shot, I know.....

3. Very weird stuff on the systems of your clients. Cookies are supposed to be private so I can't understand how and why user B would be able to read user A's cookies. Just like you, impossible for me to reproduce here.

Sorry I can't help much further.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #5 (permalink)  
Old July 1st, 2009, 01:18 PM
Authorized User
 
Join Date: Oct 2007
Location: , , .
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Shopping Cart Crossing Over

Hi Imar,

I modifed it for my application as follows:
1. Display many items on the screen (Default.aspx).
2. Enter multiple items' Quantity
3. Add to Cart
4. Continue Shopping then Goto 1.

A. To do this, I used array to enter multiple items' quantity. I placed this array under App_Code as Class. Does this make Crossing Over problem?

B. I moved this array from App_Code Class to Default.aspx where I display mutiple items. Is this safe and right then?

I attached codes below:

Public Shared Quantities(500, 4) As Integer '0:index, 1:quantity, 2:prodid, 3:errormask
Public Shared dliRowCount, dliQuantity As Integer

.
.
Protected Sub btnAddAll_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles btnAddAll.Click
Dim i As Integer
Dim j As Integer = dliRowCount - 1
Dim errMessage As String = ""
For i = 0 To j
If Quantities(i, 3) Then 'Is ever set Error mark?
errMessage = errMessage & Titles(i, 0) & ", "
End If
Next
If errMessage <> ""Then
lblResults.Text = " Over-quantities in items " & Left(errMessage, Len(errMessage) - 2) & ". Please correct Quantities!!!"
Else
For i = 0 To dliRowCount - 1
If Quantities(i, 1) > 0 Then 'Add Product when Quantity > 0
Dim myProduct As Product = ShopManager.GetProduct(Quantities(i, 2))
For j = 0 To Quantities(i, 1) - 1 'Add upto Quantity or Available
ShopManager.AddProductToCart(myProduct)
Next j
End If
Next
Response.Redirect("~/Shop/ShoppingCart.aspx")
End If
End Sub


Thanks Imar,
HD

Last edited by hdpark; July 1st, 2009 at 01:21 PM..
  #6 (permalink)  
Old July 1st, 2009, 01:29 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Ah, that explains it. Take a look at this:

Code:
Public Shared Quantities(500, 4) AsInteger' 0:index
A Shared variable exists on the class where you define it. At any tme, there's only one instance of that property throughout the entire application domain. In other words: all users have access to the same variable. If user A adds an item and user B queries the Quantities property, she'll see stuff added by user A. This is a bad design choice, as you won't be able to differentiate among users anymore. Now, take another look at my ShoopingCart property:

Code:
 
Public Shared ReadOnly Property ShoppingCart() As ShoppingCart
  Get
    If HttpContext.Current.Session("ShoppingCart") Is Nothing Then
      HttpContext.Current.Session("ShoppingCart") = New ShoppingCart()
    End If
    Return CType(HttpContext.Current.Session("ShoppingCart"), ShoppingCart)
  End Get
End Property
Althrough the property itself is marked as shared, its backing store is user scoped. This gives each user a unique shopping cart which isn't shared by others.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shopping Cart seannie ASP.NET 2.0 Basics 0 December 12th, 2006 10:28 AM
Shopping Cart inkrajesh ASP.NET 1.0 and 1.1 Basics 2 February 28th, 2006 03:08 AM
shopping cart xipnl BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 June 10th, 2005 07:00 PM
Shopping cart Manoj babu General .NET 0 February 14th, 2005 04:20 AM



All times are GMT -4. The time now is 01:57 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.